View Single Post
  #5 (permalink)  
Old 08-08-2008, 08:15 AM
EternalWolf EternalWolf is offline
Registered User
 
Join Date: Aug 2008
Posts: 3
ok, I edited the code a little and found a solution!

here is the fully functional finished code:

Code:
<?php
$dbhost = 'mysql3.freehostia.com';
$dbuser = 'vinmar10_net';
$dbpass = 'Master';

$link = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql');

$add_credits = 1000;
$username = mysql_real_escape_string($_POST['entered_username'],$link);

$dbname = 'vinmar10_net';
mysql_select_db($dbname);

if($sql_query = mysql_query("SELECT `extcredits2` FROM `cdb_members` WHERE `username` = '$username'")) {
while($rs = mysql_fetch_array($sql_query)) {
$creditamt = $rs[0] + 1;
}
$sql_query = "UPDATE cdb_members SET extcredits2 = extcredits2+ '$add_credits' WHERE username = '$username'";
if(mysql_query($sql_query)) {
echo "Credits Purchased Successfully";
}
else {
die("The procedure died while trying to add credits. Following is the error that was generated:\n\r".mysql_error());
}
}
else {
die("The procedure died while trying to retrieve information from the database. Following is the error that was generated:\n\r".mysql_error());
}
?>
Thank you for all your help!
I'll be adding your name and the website in comments.

regards,
vince

Last edited by EternalWolf; 08-08-2008 at 08:31 AM.
Reply With Quote