This is the code I have, but I get this error when I try to get variable from the url: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
The URL variable DEVID is a long string of characters, numbers, dashes, and underscores. Any ideas on what is wrong?
<?php
$con = mysql_connect("server","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$result = mysql_query("SELECT * FROM $user WHERE DEVID=$DEVID");
while($row = mysql_fetch_array($result))
{
if (($row["FN"]) == NULL){
echo '<meta http-equiv="refresh" content="1;url=../register/default.php?user=';
echo $_GET["user"];
echo '&DEVID=';
echo $_GET["DEVID"];
echo '">Please hold, we are taking you to the registration page.<br/><br/>';
}
}
mysql_close($con);
?>
echo mysql_error();right after your mysql_query and google about sql injections. PS: any reason to show userplease holdpage instead of immediate redirect?$useror$DEVID. If by$useryou meant a table nameduser, then remove the$sign, and add another check just before the while loop -if ($result).......GET[]them from the URL in some other piece of code? You need to do that before you use them, I believe. Like this:$user = GET['user'];And this is a SQL injection waiting to happen... I'd make sure to scrub the variables at least.