Jump to content

[SOLVED] Datebase won't verify


lookee

Recommended Posts

Everything works except the verification of whether a row is already in table.

Basicially if 1 row exists, code should quit running and echo "already purchased" message.

 

Code

 

----------------------------

 

// Select the Database

$db_select=mysql_select_db($db_name);

if (!$db_select)

{

die ("Couldn't select the database: <br/>". mysql_eror());

}

 

// Assign the Query

$query = "SELECT * FROM shoes WHERE username = '$username' AND size > 0";                  <---------- If size greater than 0 already placed an order)

// Execute the Query

$result = mysql_query($query);

 

if (!$result)

{

die ("Line 117 Could not query the database: <br />". mysql_error());

}

 

if ($query == 1)                            <----- if 1 row exists - order for shoes already in database, so exit

{

die ("You already made a request!"); 

  }

 

mysql_query("INSERT INTO shoes

 

VALUES('purchase_number','$username','$first_name','$last_name','$address','$city','$state','$zip','$email','$size','date') ")

or die(mysql_error());

 

Header("Location: successful_purchase.php");

 

include 'close_db.php';

?>

 

 

Any help with my logic would greatly help!

Link to comment
https://forums.phpfreaks.com/topic/131301-solved-datebase-wont-verify/
Share on other sites

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.