How can I construct a mysql query with php variable in it, does everyone know?
like:
$result=mysql_db_query($db, "SELECT * FROM table WHERE user=$user");
This second parameter has given me a lot of problems.
Try:
$result=mysql_db_query($db, "SELECT * FROM table WHERE user='$user'");
The variable needs the ''
Make that:
$result=mysql_query("SELECT * FROM table WHERE user='$user'", $db);
Not fully awake yet 😉
What's the difference between mysql_db_query(0 and mysql_query, they both seem to have database connection capability
mysql_query uses the db from mysql_select_db($db)
IIRC, mysql_db_query simply lets you specify the database while mysql_query doesn't. Since the link also specifies the database, I don't understand what's the point.
-jani
It seems pointless, but it saves the trouble of having to remember and track which LinkID is to which database.