Possible Duplicate:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
$err = mysql_query("INSERT INTO tridy (id,NazevTridy,url) VALUES (
'$i',
'$tridy->find('div[class=rozvrhseznam]', 0)->find('a[href]', $i)->outertext',
'$tridy->find('div[class=rozvrhseznam]', 0)->find('a[href]', $i)->href')");
mysql_error($err); // line 97
Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /hosting/www/cran-web.com/www/rozvrh/engine.php on line 97
— lines 2-6:
$username="*****.com";
$password="*********";
$database="*********";
mysql_connect('127.0.0.1', $username, $password) or die('Could not connect'.mysql_error());
mysql_select_db($database) or die( "Cannot select db.");
I’m getting this error when I try to execute my query. Can you tell what does the error message mean and how to fix it?
mysql_error()expects a “Link resource” and no “result resource”. Te correct way would be something like:Mind the use of
$connection. Wile $connection could be dropped everywhere as inWhich uses the last opened connection or opens a new one by default. While depending on the default connection is bad. You might also want to look into mysqli or PDO as alternative ways to talk to MySQL.