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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.