mlummus Posted April 20, 2010 Share Posted April 20, 2010 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']; Quote Link to comment https://forums.phpfreaks.com/topic/199177-query-response-help/ Share on other sites More sharing options...
Pikachu2000 Posted April 20, 2010 Share Posted April 20, 2010 You're conflating mysql and mysqli. Use one or the other, not both. Quote Link to comment https://forums.phpfreaks.com/topic/199177-query-response-help/#findComment-1045407 Share on other sites More sharing options...
mlummus Posted April 20, 2010 Author Share Posted April 20, 2010 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); Quote Link to comment https://forums.phpfreaks.com/topic/199177-query-response-help/#findComment-1045429 Share on other sites More sharing options...
Pikachu2000 Posted April 21, 2010 Share Posted April 21, 2010 mysqli_query($db, $SQLstring); Quote Link to comment https://forums.phpfreaks.com/topic/199177-query-response-help/#findComment-1045498 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.