cmaclennan Posted July 22, 2009 Share Posted July 22, 2009 Hi guys, Im sure ive done or missed something simple but my brain is in a bit of overload at the moment and I cant seem to see what i've done wrong, I have a query below that searches for a record and returns it when found however it displays the same message of entry found even when no record is returned and i cant seem to get a different message to appear i just get parse errors. Any help would be greatly appreciated. require_once ('mysql_connect2.php'); // Connect to the db. // Make the query. $query = "SELECT * FROM powercarts WHERE cart_serial LIKE '$se' or charger LIKE '$se' or inverter LIKE '$se' or battery LIKE '$se' or battery2 LIKE '$se' or inverter2 LIKE '$se' or po LIKE '$se'"; $result = @mysql_query ($query); // Run the query. if (mysql_num_rows($result) == 1) { // If it ran OK. // Print a message. echo '<br>Your entry has been found.</br><br/>'; while ($row = mysql_fetch_array($result)){ echo 'PO: '.$row['po']; echo '<br/> Date: '.$row['date']; echo '<br/> Cart Serial: '.$row['cart_serial']; echo '<br/> Charger: '.$row['charger']; echo '<br/> Battery: '.$row['battery']; echo '<br/> 2nd Battery: '.$row['battery2']; echo '<br/> Inverter: '.$row['inverter']; echo '<br/> 2nd Inverter: '.$row['inverter2']; echo '<br/><a href="powercart_edit.php?id=' . $row['cart_serial'] . '" target="_blank">Edit</a> <a href="order_view_carts.php?id=' . $row['po'] . '" target="_blank">View</a>'; echo '<br/><br/>'; } else { // Not a valid Customer ID. echo '<div id="title">Page Error</div> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; } exit(); } mysql_close(); // Close the database connection. Quote Link to comment https://forums.phpfreaks.com/topic/167002-solved-desperate-for-some-help/ Share on other sites More sharing options...
ignace Posted July 22, 2009 Share Posted July 22, 2009 you are missing a } for the while. Quote Link to comment https://forums.phpfreaks.com/topic/167002-solved-desperate-for-some-help/#findComment-880596 Share on other sites More sharing options...
ignace Posted July 22, 2009 Share Posted July 22, 2009 require_once ('mysql_connect2.php'); // Connect to the db. // Make the query. $query = "SELECT * FROM powercarts WHERE cart_serial LIKE '$se' or charger LIKE '$se' or inverter LIKE '$se' or battery LIKE '$se' or battery2 LIKE '$se' or inverter2 LIKE '$se' or po LIKE '$se'"; $result = @mysql_query ($query); // Run the query. if (mysql_num_rows($result) == 1) { // If it ran OK. // Print a message. echo '<br>Your entry has been found.</br><br/>'; while ($row = mysql_fetch_array($result)) { echo 'PO: '.$row['po']; echo '<br/> Date: '.$row['date']; echo '<br/> Cart Serial: '.$row['cart_serial']; echo '<br/> Charger: '.$row['charger']; echo '<br/> Battery: '.$row['battery']; echo '<br/> 2nd Battery: '.$row['battery2']; echo '<br/> Inverter: '.$row['inverter']; echo '<br/> 2nd Inverter: '.$row['inverter2']; echo '<br/><a href="powercart_edit.php?id=' . $row['cart_serial'] . '" target="_blank">Edit</a> <a href="order_view_carts.php?id=' . $row['po'] . '" target="_blank">View</a>'; echo '<br/><br/>'; } } else { // Not a valid Customer ID. echo '<div id="title">Page Error</div> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; } mysql_close(); // Close the database connection. Always remember to properly indent your code. I fixed it for ya. Quote Link to comment https://forums.phpfreaks.com/topic/167002-solved-desperate-for-some-help/#findComment-880599 Share on other sites More sharing options...
cmaclennan Posted July 22, 2009 Author Share Posted July 22, 2009 Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/167002-solved-desperate-for-some-help/#findComment-880602 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.