😕
Hey,
I having a real big problem with the following error
Warning: mysql_fetch_array (): supplied argument is not a valid MySQL result resource in /home/a8567431/public_html/viewpassanger.php on line 23
I have a page called show.php which passes two variables called flightnum and flightdate. The second page called viewinfo.php uses the $_GET function to store flightnum in var $a and flight date into $b.
For example the show.php will pass 1895 as flightnum and 05/04/09 as flightdate. The viewinfo.php then store these value two $a and $b I know this Is working because when I just echo out $a and $b I get the correct results.
Also when I query the database using the following code
$sql = 'SELECT * FROM passanger WHERE Flightnum = 1895 and date = "05/04/09"';
it bring up the correct results. I only get the error when I replace the value with the variable $a and $b
$q = 'SELECT * FROM passanger WHERE Flightnum = $a and date = $b';
here is the code for the viewinfo.php page
<?php
$a = $GET["flightnum"];
$b = $GET["flightdate"];
$conn = mysql_connect("mysql7.000webhost.com","a8567431_aviance","xxxx");
mysql_select_db("a8567431_aviance");
$q = 'SELECT * FROM passanger WHERE Flightnum = $a and date = $b';
$result = mysql_query($q);
?>
<table border='1' cellpadding = '0' cellspacing ='0' align ="center">
<tr><th width = "20%">passanger name</th><</tr>
<?php
while($row = mysql_fetch_array($result))
{
echo "<tr><td>";
echo $row[Pname];
echo "</td><td>";
echo $b;
echo "</td></tr>";
}
?>
Please can some one help
Ed