Topshed Posted February 29, 2008 Share Posted February 29, 2008 My Select script is behaving very strangely Sometime I get a Blank screen for one number (like the record does not exist) and the expected result from another so a code snippit to report a failure to find the record would help it is run from a template so only the two inputs change ? <?php $tble = 'aefe'; $modnum = 10000; //INPUT A $suff = ''; //INPUT B include_once"../includes/My_conn.php"; $connect = mysqli_connect($host,$account,$password) OR DIE("Error !! Unable to connect to database"); $db = mysqli_select_db($connect,"$dbname") OR DIE( "Unable to select database "); $db = "SELECT * FROM $tble WHERE model = $modnum "; if ($suff) { } else { $db .= "AND sufix = '$suff'"; } if ($result = mysqli_query($connect,$db)) { if (mysqli_num_rows($result)) { $row = mysqli_fetch_assoc($result) // while ($row = mysqli_fetch_assoc($result)){ ?> <table> - - - - </table> } } ?> If I replace the row with the while row that is commented out it does work sort of but gives me all records with that modnum if I enter $suff = ''; //INPUT B but find the other records with any other letter if I change if ($suff) { to if (!$suff) { The whole result thing is reversed Thanks Roy... Quote Link to comment Share on other sites More sharing options...
btherl Posted February 29, 2008 Share Posted February 29, 2008 If the select returns multiple rows, then you must choose which row you want. I recommend printing out $db for verification. It may not be what you expect. Quote Link to comment Share on other sites More sharing options...
Zyphering Posted February 29, 2008 Share Posted February 29, 2008 Sorry for the Spam I just create a new account and I am not able to post/preview a new message. Any Idea on this problem. Quote Link to comment Share on other sites More sharing options...
Topshed Posted February 29, 2008 Author Share Posted February 29, 2008 btherl wrote I recommend printing out $db for verification. It may not be what you expect. Oh how right you were, I have solved all my problems with this script AND deleted half dozen lines of code in the process Thank you for the help Regards 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.