Jump to content


Photo

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


  • Please log in to reply
4 replies to this topic

#1 wetmau5

wetmau5

    New Member

  • Members
  • Pip
  • 1 posts

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 Files

  • Attached File  form.php   1.91KB   71 downloads


#2 drewdin

drewdin

    Super Veteran Member

  • Members
  • PipPipPipPipPipPipPipPipPipPipPip
  • 608 posts
  • Gender:Male
  • Location:Boston

Posted 05 October 2012 - 06:01 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.


you cant mix mysql and mysqli functions.

#3 rhender

rhender

    Active Member

  • Members
  • PipPip
  • 10 posts

Posted 10 October 2012 - 07:37 AM

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.

#4 drewdin

drewdin

    Super Veteran Member

  • Members
  • PipPipPipPipPipPipPipPipPipPipPip
  • 608 posts
  • 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.

Edited by drewdin, 12 October 2012 - 11:27 AM.


#5 rhender

rhender

    Active Member

  • Members
  • PipPip
  • 10 posts

Posted 16 October 2012 - 01:28 PM

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 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users