Smudly Posted June 16, 2010 Share Posted June 16, 2010 For some reason, the following code is giving this error: Parse error: syntax error, unexpected '}' in /home/content/s/m/u/smudlys/html/ratestest.php on line 21 This is the line after the first if statement. MySql version: 5.0.19 Here is my code: <?php /// Include Admin Page Here /// include('inc/connect.php'); $user = $_SESSION['username']; $getmember = mysql_query("SELECT * FROM users WHERE username='$user'"); while ($row = mysql_fetch_assoc($getmember)) { $member = $row['member']; } $getlevel = mysql_query("SELECT * FROM userstats WHERE username='$user'"); while ($row = mysql_fetch_assoc($getlevel)) { $level = $row['level']; } $addrate = .005; if($member==0){ $rate = ($level*$addrate+.50) } if($member==1){ $rate = ($level*$addrate+1) } ?> Link to comment https://forums.phpfreaks.com/topic/204996-getting-error-when-everything-looks-right/ Share on other sites More sharing options...
firedealer Posted June 17, 2010 Share Posted June 17, 2010 if($member==1){ $rate = ($level*addrate+1) } ?> Need to add $ to addrate. Just FYI. Link to comment https://forums.phpfreaks.com/topic/204996-getting-error-when-everything-looks-right/#findComment-1073184 Share on other sites More sharing options...
Smudly Posted June 17, 2010 Author Share Posted June 17, 2010 Just noticed that, and fixed it. It is still giving me issues. Link to comment https://forums.phpfreaks.com/topic/204996-getting-error-when-everything-looks-right/#findComment-1073185 Share on other sites More sharing options...
mrMarcus Posted June 17, 2010 Share Posted June 17, 2010 did you fix the line above it too? if($member==0){ $rate = ($level*$addrate+.50) <-- need a ; } if($member==1){ $rate = ($level*$addrate+1) <-- need a ; } Are you getting a new error? Link to comment https://forums.phpfreaks.com/topic/204996-getting-error-when-everything-looks-right/#findComment-1073186 Share on other sites More sharing options...
Smudly Posted June 17, 2010 Author Share Posted June 17, 2010 Those darn semi colons. Thank you! it works Except one small problem. When I try echoing out $rate, it says it is .5 When in reality, it should be .505 (user's level is 1, and member=0) How do I make it include all the decimal places? Thanks Link to comment https://forums.phpfreaks.com/topic/204996-getting-error-when-everything-looks-right/#findComment-1073189 Share on other sites More sharing options...
mrMarcus Posted June 17, 2010 Share Posted June 17, 2010 If $level equals 1, and $addrate is .005, the code returns .505 as you say it should. ((1*.005) + .50) But to be sure about retaining number integrity, cast them whenever possible: $addrate = (float)0.005; Link to comment https://forums.phpfreaks.com/topic/204996-getting-error-when-everything-looks-right/#findComment-1073199 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.