Topshed Posted November 22, 2007 Share Posted November 22, 2007 G'day I am totaly new to php and I have spent a whole morning trying to debug a simple piece of test code and I need some help <?php $host = "localhost"; $account = "root"; $password = "testing"; $dbname = "steam"; // Make connection to database If no connection made, display error Message $connect = mysqli_connect($host,$account,$password) OR DIE("Error !! Unable to connect to database"); echo '<b>Step 1:</b> Connected successfully! <BR>'; // Select database or print error message if unsuccessful $db = mysqli_select_db($connect,"$dbname") or die( "Unable to select database ".steam); echo '<b>Step 2:</b> Connected to ('.$dbname.') successful!<BR>'; $db="SELECT * FROM lner WHERE br_no = lner"; $result = mysqli_query($connect,$db); // it appears to work up to this point !!!! Line 20 coms next $row = mysqli_fetch_array($result); ?> Then I get this error:- mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in test-1.php on line 20 Please help somebody I cannot believe I am that dumb ? thanks in advance Topshed (Roy) ??? Quote Link to comment Share on other sites More sharing options...
trq Posted November 22, 2007 Share Posted November 22, 2007 You need to check your result prior to using it. if ($result = mysqli_query($connect,$db)) { $row = mysqli_fetch_array($result); } ps: The problem is your query is failing. It should look like.... $db = "SELECT * FROM lner WHERE br_no = 'lner'"; Quote Link to comment Share on other sites More sharing options...
Topshed Posted November 22, 2007 Author Share Posted November 22, 2007 Thank you, So simple If you know what your talking about. Can I just ask another question The book I am working from gives examples for post_gre and that is not helping I believe my code should return one record as the search field "br_no" is unique How can I output that record to screen please Roy.. Quote Link to comment 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.