Jump to content

[SOLVED] Desperate for some help.


cmaclennan

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/167002-solved-desperate-for-some-help/
Share on other sites

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.

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.