Jump to content

Query Response Help


mlummus

Recommended Posts

I'm getting the following response when running the code below. The input should be calling a valid record. Any idea where the errors may be coming from? I'm am able to connect to the database and table using the same credentials in other similar php programs (for instance, a call all records program).

 

Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /net/oitg/export/home1/home3/mdl0002/public_html/assignment1/lookupstudent.php  on line 31

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /net/oitg/export/home1/home3/mdl0002/public_html/assignment1/lookupstudent.php on line 31

 

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /net/oitg/export/home1/home3/mdl0002/public_html/assignment1/lookupstudent.php on line 33

 

No Records Found.

 

$db = mysqli_connect('host','user','password');

if (!$db)
   	{
   echo "Error: Could not connect to database.  Please try again later.";
           exit;
        }
   mysqli_select_db($db, "database");


$SQLstring = "SELECT * FROM student WHERE id = '$id'";
$QueryResult = mysql_query($SQLstring);

$NumRows = mysqli_num_rows($QueryResult);   
if ($NumRows == 0)
echo "<p>No Records Found.";
else {
$Row = mysql_fetch_array($QueryResult);
$id = $Row['id'];
$name_last = $Row['name_last'];
$name_first = $Row['name_first'];
$email = $Row['email'];
$class = $Row['class'];
$major = $Row['major'];
$living = $Row['living'];  

Link to comment
https://forums.phpfreaks.com/topic/199177-query-response-help/
Share on other sites

Thanks. I must have missed the "i" on that one. I've fixed that error but am now receiving "Warning: mysqli_query() expects at least 2 parameters, 1 given." Would would be the second parameter it is looking for?

 

$SQLstring = "SELECT * FROM student WHERE id = '$id'";
$QueryResult = mysqli_query($SQLstring);

Link to comment
https://forums.phpfreaks.com/topic/199177-query-response-help/#findComment-1045429
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.