MySQL Forums
Forum List  »  PHP

Re: Warning: mysql_fetch_assoc()
Posted by: George Gallen
Date: November 03, 2015 02:45PM

OK - well - the problem is in your mysql_query() call, and your connect and database selection. When you do your mysql_connect you need to assign it to a handle - $dbhandle=mysql_query(....). When you do your mysql_select_db() you need to supply the $dbhandle as the second paramter. Also you need to supply that $dbhandle in the mysql_query() as the second paramter and the results are assigned $result = mysql_query($sql, $dbhandle) - then you use the $result for the mysql_fetch_assoc().

That will get it working....however, you still have the deprecation to worry about. It's fairly straigtforword converting over - unless your planning on upgrading your php6 you should be ok to continue using the old methods - but from what I understand php6 will not allow them - and if your hosting provider is using php6 - you will have to go to mysqli(). But for now - you have some time to slowly migrate your routines.

you just add an i to the mysql_... to mysqli_
However....there are a few gotcha's to lookout for.

1. the connect now contains the db select also - you don't need the db_select
2. the mysql_query and mysqli_query have their paramters reversed so check the order of the paramters on any of the mysqli_ calls you make.

Options: ReplyQuote


Subject
Written By
Posted
Re: Warning: mysql_fetch_assoc()
November 03, 2015 02:45PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.