tags:

views:

124

answers:

4

I'm using PHP in a Windows/IIS environment and found this db related code not to work:

$result = mysql_query("SELECT * FROM users WHERE id=12);

So is there an alternative to mysql_query?

+5  A: 

$result = mysql_query("SELECT * FROM users WHERE id=12"); // missing " at the end of query ?

fornve
A: 

And now it works. I'm sorry guys, I sweat I changed nothing.

A: 

It's possible that the php_mysql library wasn't loaded. You need to be sure that php_mysql.dll is being loaded in the php.ini file, usually like this:

extension=php_mysql.dll
mechler
A: 

I am getting the same issue as well. I am able to select the proper schema using mysql_select_db and then on the very next line mysql_query is throwing a 500 server error without putting anything in the php error log. Error reporting is cranked to E_ALL as well...

I am able to connect to the database using the same credentials and run the query with records returned. It's really annoying since it was working last night and now doesn't work first try in the morning.

EDIT: Okay, so I had an epiphany it turns out the database abstraction library I was using (metabase) was employing persistent connections when connecting to MySQL. I swtiched the config so that it was using mysql_connect to connect rather than mysql_pconnect and everything worked again. In case you are not using mysql_pconnect, don't forget the fourth parameter new_link in mysql_connect to force a new connection.

Matthew Purdon