PDA

View Full Version : Supplied argument is not a valid MySQL-Link


mancroft
06-24-2003, 11:03 PM
I am trying to get php to send an email part of which is a display of a MySQL table.

The code below may or may not be correct but I am getting the error message:

Warning: Supplied argument is not a valid MySQL-Link resource in /home/mancroft/www/test/emailform.php on line 32

plus two similar messages for other lines.

Any ideas please?

MYSQL_CONNECT(localhost, mancroft, xxxxxx) OR DIE("Unable to connect");

mysql_select_db("mancroft_test",$db);

$result = mysql_query("SELECT * FROM cart",$db);
if ($result === false) die("failed");

while ($row=mysql_fetch_row($result)) {
$RBI=$row[0];
$RUI=$row[1];
$RON=$row[2];
}

$serveroutput = "$RBI $RUI $RON";

raf
06-24-2003, 11:37 PM
the problem is that you don't have a 'handler' for the connection. Normally, i use something like

$con=MYSQL_CONNECT(localhost, mancroft, xxxxxx) OR DIE("Unable to connect");
mysql_select_db("mancroft_test",$con);
$result = mysql_query("SELECT * FROM cart",$con);


this $con can then be used as an identified in the other mysql functions.
This is not required. You can leave the identifier out (but then you als need to remove it from the functions. Like
mysql_select_db("mancroft_test")

PHP will then select the active connection.

But it's good practise to use an identifier.

mancroft
06-25-2003, 09:00 AM
Thanks, raf.