Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/139448-data-is-not-loading-into-mysql/
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.