I have looked at many php scripts for accessing mysql databases and every one is structured along the lines of the following.
$db = mysql_connect($server, $db_user,$db_pass);
mysql_select_db($database,$db);
$insert = mysql_query(“INSERT INTO useronline VALUES (‘$timestamp’,’$REMOTE_ADDR’,’$PHP_SELF’)”,$db);
If I try to use these on my server, I get errors.
$dbh = mysql_connect($db_host, $db_user, $db_password);
mysql_select_db($db_name);
$dbc = mysql_query(“select * from grandscores”);
You can see that I have to leave out the mysql handle returned by mysql_connect, in both mysql_select_db and mysql_query otherwise it will not work.
int mysql_select_db(MYSQL *mysql, const char
int mysql_query(MYSQL *mysql, const char
In mysql_select_db and mysql_query, the handle is the first parameter which is different to both the above examples.
Can anyone explain what is going on?