O'Reilly Forums: Fatal Error: Call To A Member Function Fetch_Assoc() On A Non-Object - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Fatal Error: Call To A Member Function Fetch_Assoc() On A Non-Object

#1 User is offline   wetmau5 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 05-October 12

Posted 05 October 2012 - 04:11 AM

I am trying to create a small form for people to come to my website and simply enter the following information:
  • Name
  • Surname
  • Email Address


It should send this information back into my table from my database.

...Now here is where things get "complex" (...well it is to me, okay? )... :P

If the email address does not exist in our table, then it must echo "Email Address Added. Thank you!". Otherwise if it does, then it must echo "Email address already exists!"

For some reason it is not doing this. It is spitting out this error:
Fatal error: Call to a member function fetch_assoc() on a non-object in C:\wamp\www\addemail.php on line 46

I have attached my php code.

Attached File(s)

  • Attached File  form.php (1.91K)
    Number of downloads: 63

0

#2 User is offline   drewdin 

  • Super Veteran Member
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 608
  • Joined: 11-February 10
  • Gender:Male
  • Location:Boston

Posted 05 October 2012 - 06:01 AM

View Postwetmau5, on 05 October 2012 - 04:11 AM, said:

I am trying to create a small form for people to come to my website and simply enter the following information:
  • Name
  • Surname
  • Email Address


It should send this information back into my table from my database.

...Now here is where things get "complex" (...well it is to me, okay? )... :P

If the email address does not exist in our table, then it must echo "Email Address Added. Thank you!". Otherwise if it does, then it must echo "Email address already exists!"

For some reason it is not doing this. It is spitting out this error:
Fatal error: Call to a member function fetch_assoc() on a non-object in C:\wamp\www\addemail.php on line 46

I have attached my php code.


you cant mix mysql and mysqli functions.
0

#3 User is offline   rhender 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 10
  • Joined: 13-August 12

Posted 10 October 2012 - 07:37 AM

View Postdrewdin, on 05 October 2012 - 06:01 AM, said:

you cant mix mysql and mysqli functions.



Hmmm... interesting. I was mixing mysql and mysqli functions in one of my experiments, and I think I was having problems, although I'm not sure. It may have actually worked, I can't remember right now.

But I googled just what you said and found the following link in a forum:

http://forums.htmlhe...showtopic=11852

A tiny bit interesting.
0

#4 User is offline   drewdin 

  • Super Veteran Member
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 608
  • Joined: 11-February 10
  • Gender:Male
  • Location:Boston

Posted 12 October 2012 - 11:25 AM

I had a similar issue when i was learning php, you cannot mix mysql and mysqli functions, you have to use one or the other.

" I was mixing mysql and mysqli functions in one of my experiments, and I think I was having problems, although I'm not sure. It may have actually worked, I can't remember right now"

In the form.php file you included, you were indeed mixing mysql and mysqli functions. that is why is was giving you the error you have listed.

When you made the change did your code work? that's the real question, let us know.

This post has been edited by drewdin: 12 October 2012 - 11:27 AM

0

#5 User is offline   rhender 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 10
  • Joined: 13-August 12

Posted 16 October 2012 - 01:28 PM

View Postdrewdin, on 12 October 2012 - 11:25 AM, said:

I had a similar issue when i was learning php, you cannot mix mysql and mysqli functions, you have to use one or the other.

" I was mixing mysql and mysqli functions in one of my experiments, and I think I was having problems, although I'm not sure. It may have actually worked, I can't remember right now"



Hey there, yeah I'm not the original poster. But I actually have a file in which I am using both mysql and mysqli functions right now, and it seems to be working fine.

I am using the mysql_escape_string function for variables from a form, and then I am using the mysqli_query function as well.

I haven't seen any problems yet, although I think I did see somewhere recently that the mysql_escape_string function is now deprecated and I should replace it with something else. I just don't know what to replace it with... ?????????
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users