hi guys
i keep getting this error message:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in c:\program files\apache group\apache\htdocs\getdata.php on line 9
MySQL query select student_id from students where student_id='994519' failed. Error if anyzzzz:
this comes from a previous html page which is like this
request.html
<form method="POST" action="getdata.php">
Enter User Number: <input type="text" name="id"><br>
<input type="submit">
</form>
What should be happening is user enters a student_id from request.html, the next page "getdata.php" should then show the all the details in table students in fields....
<?php
global $link;
$query = "select student_id from students where student_id='$id'";
//will work. then to put all the results in textboxes
// Run query:
$result=mysql_query($query, $link) or die("MySQL query $query failed. Error if anyzzzz: ".mysql_error());
$data = mysql_fetch_array($result);
?>
<form action="<?=$_SERVER["PHP_SELF"]?>" method="POST">
<?php
print "Search for Staff Member<input type=\"text\" name=\"id\" value=\"\"><br />\n";
print"<TABLE>";
print "<input type=\"text\" name=\"student_id\" value=\"{$data[0]}\"><br />\n";
echo "</tr>";
echo "<input type=\"text\" name=\"first_name\" value=\"{$data[1]}\"><br />\n";
echo "<input type=\"text\" name=\"last_name\" value=\"{$data[2]}\"><br />\n";
echo "<input type=\"text\" name=\"faulty_id\" value=\"{$data[3]}\"><br />\n";
echo "<input type=\"text\" name=\"date_started\" value=\"{$data[4]}\"><br />\n";
/*
echo "<input type=\"text\" name=\"group_id\" value=\"{$data[5]}\"><br />\n";
echo "<input type=\"text\" name=\"module_id\" value=\"{$data[6]}\"><br />\n";
echo "<input type=\"text\" name=\"module_id2\" value=\"{$data[7]}\"><br />\n";
echo "<input type=\"text\" name=\"module_id3\" value=\"{$data[8]}\"><br />\n";*/ ?>
<input name="Search" type="submit" value="Search">
<input name="submit" type="submit" value="Submit">
<input type="submit">
</form>
thanks for your help