# DATA is not loading into mySQL

**URL:** <https://forum.kirupa.com/t/data-is-not-loading-into-mysql/278727>\
**Category:** Uncategorized\
**Created:** [January 4, 2009, 6:19pm UTC](https://forum.kirupa.com/t/data-is-not-loading-into-mysql/278727 "2009-01-04T18:19:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cyandi\_man](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@cyandi\_man](https://forum.kirupa.com/u/cyandi_man)\
**Post date:** [January 4, 2009, 6:19pm UTC](https://forum.kirupa.com/t/data-is-not-loading-into-mysql/278727/1 "2009-01-04T18:19:42Z")

</div>

hi gang just wondering if you would be able to help me with this php code here. the data ‘$amount’ and ‘$pnts’ comes from a flash file which has been verified to not contain the error.

what this php code is trying to do is check total points on a table in sql and comparing with the points that the user wishes to redeem. If the total points on mySQL is sufficient enough - the points are redeemed and the redeemed points go into a ‘total points redeemed’ table.  
if not then the appropriate error message is sent to the swf.

session\_start();  
$clientN = $\_SESSION[‘client’];  
$me = $\_SESSION[‘name’];  
$me2 = $\_SESSION[‘name2’];  
if (@$\_SESSION[‘auth’]!=“yes”)  
{  
header(“Location: …/personal\_account\_login.php”);  
exit();  
}$user=“Myuser”;  
$host=“localhost”;  
$password=“MYpass”;  
$database = “myDatabase”;  
$connection = mysql\_connect($host,$user,$password)  
or die (“couldn’t connect to server”);  
$db = mysql\_select\_db($database,$connection)  
or die (“Couldn’t select database”);  
$db = mysql\_select\_db($database,$connection)  
or die (“Couldn’t select database”);

$query1 = “SELECT totalpnts FROM patient\_totals WHERE clientNumber=’$clientN’”;  
$result1 = mysql\_query($query1) or die(mysql\_error());  
while($row1 = mysql\_fetch\_array($result1)){  
extract($row1);  
if ($pnts \> $totalpnts) {  
Print “\_root.status=SORRY! You Do Not Have Enough Health Points to Redeem This Item - Please Choose Again!”;  
}  
else  
{  
$newtotal= $totalpnts - $pnts;  
$queryx = “UPDATE patient\_totals SET totalpnts=’$newtotal’ WHERE clientNumber=’$clientN’”;  
$resultx = mysql\_query($queryx) or die(mysql\_error());

$query3 = “INSERT INTO redemption(clientNumber, firstName, lastName, product, amount, pnts)  
VALUES(’$clientN’, ‘$me’, ‘$me2’, ‘$item’,’$amount’, ‘$pnts’)”;

$result3= mysql\_query($query3)  
or DIE(“Unable to redeem your points at this time…please try again later.”);  
Print “\_root.status=You have successfully redeemed $pnts Points! You will receive an email with your voucher attached within 24hrs. Thank you!”;  
}  
}

any help would be greatly appreciated - THANKS!
