vForums Support > Programming & Coding :: Programming Discussion :: > Shop Code Help

Shop Code Help - Posted By dog199200 (dog199200) on 27th Jan 10 at 7:27am
Ok here is the thing, I have been working on building my own personal shop system them relies on a unit of payment called credits which a set amount of credits can be paid for via real money. The thing is though, this is my first real big project using a database outside of storing data for a video game, and i keep running into tiny problems. On problem I am having now is with this code:


Code:
 
  1. $vf_username = $user_info[user_name];
  2. $data['credits'] = $new_total;
  3.  
  4.  
  5. $credits = mysql_query("SELECT * FROM credits WHERE user_name = '$vf_username'") or die(mysql_error());
  6. $credit_info = mysql_fetch_array($credits);
  7.  
  8. if($credit_info['credits'] => $total) {
  9. $new_total = $credit_info['credits'] - $total;
  10. $db->query_insert("credits", $data);
  11. } else {
  12. echo "You need more credits to make this purchase. You can purchase credits by <a href=\"#\">clicking here</a>.";
  13. }
 



for some reason it is giving me this error:


Code:
 
  1. Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/tameron/public_html/divineshadowsonline.com/store/cart/index.php on line 69
 



What that code there does is check my database for the amount of credits assigned to that account by running a check on the username, matching up with the username assign in the array first. Then it runs a check to see if the user has equal to or more credits then the total amount of all the objects they want to buy. If they have more or equal to the amount, then the sum of their credits minus thats of the total sum becomes a new variable called $new_total, which is them wont to the database, over their old amount of credits. But if they don't have equal to enough they get the "You need more credits to make this purchase." message.

Over all the idea is sound, ut I have no idea why i am getting the T_DOUBLE_ARROW error {Unsure}

Re: Shop Code Help - Posted By peter (peter) on 1st Feb 10 at 12:27am
Your issue is this line...

Code:
 
  1. if($credit_info['credits'] => $total) {
 


Your operator is wrong, change it to <= (or >= depending on which side of the operator has the credits available).

{Smile}

Re: Shop Code Help - Posted By dog199200 (dog199200) on 1st Feb 10 at 12:36am
oh ok thank you so much {Smile}