AsiaUnderworld Posted December 28, 2008 Share Posted December 28, 2008 <? if(isset($_POST['travel'])) $id = secure($_SESSION['user_id']); $id = $id[0]; $sql = "SELECT location_id FROM user_stats WHERE user_id='$id'"; $result = mysql_query($sql); $firstcheck = "SELECT ticketprice FROM airport WHERE id='1' "; $firstcheck1 = "SELECT ticketprice FROM airport WHERE id='2' "; $firstcheck2 = "SELECT ticketprice FROM airport WHERE id='3' "; $firstcheck3 = "SELECT ticketprice FROM airport WHERE id='4' "; $secondcheck = mysql_query($firstcheck); $secondcheck1 = mysql_query($firstcheck1); $secondcheck2 = mysql_query($firstcheck2); $secondcheck3 = mysql_query($firstcheck3); $price = mysql_result($firstcheck); $price1 = mysql_result($firstcheck1); $price2 = mysql_result($firstcheck2); $price3 = mysql_result($firstcheck3); if ($_POST['radio']) { $radio=strip_tags($_POST['radio']); if (!ereg('[^0-9]',$radio)) { if ($radio == "1") { $costs = $price ; $to = "Chicago"; } elseif ($radio == "2") { $costs = $price1; $to = "Detroit"; } elseif ($radio == "3") { $costs = $price2 ; $to = "New York"; } elseif ($radio == "4") { $costs = $price3 ; $to = "Washington"; } } if ($fetch->lasttravel > time()) echo "You cannot travel for another ".maketime($result->lasttravel)." "; elseif ($costs > $result->money) echo " You don't have enough money for this ticket" ; } elseif ($costs <= $result->money) { } elseif ($to == $result->location_id) echo " You are already in this city. " ; { } if ($to != $result->city) { $flightcosts = $sql->money - $costs; $now = time() + 3600; mysql_query("UPDATE user_stats SET location_id='$to', money='$flightcosts' , lasttravel='$now' WHERE user_id='$id'"); } ?> These are the errors it shows Warning: Wrong parameter count for mysql_result() in /home/djwdesi/public_html/gangster/airport.php on line 37 18:35 pm: Warning: Wrong parameter count for mysql_result() in /home/djwdesi/public_html/gangster/airport.php on line 38 18:35 pm: Warning: Wrong parameter count for mysql_result() in /home/djwdesi/public_html/gangster/airport.php on line 39 18:35 pm: Warning: Wrong parameter count for mysql_result() in /home/djwdesi/public_html/gangster/airport.php on line 40 18:35 pm: Notice: Undefined index: radio in /home/djwdesi/public_html/gangster/airport.php on line 44 18:35 pm: Notice: Trying to get property of non-object in /home/djwdesi/public_html/gangster/airport.php on line 76 18:35 pm: Notice: Undefined variable: costs in /home/djwdesi/public_html/gangster/airport.php on line 76 18:35 pm: Notice: Trying to get property of non-object in /home/djwdesi/public_html/gangster/airport.php on line 83 18:35 pm: Notice: Undefined variable: to in /home/djwdesi/public_html/gangster/airport.php on line 83 Error lines respectively are: $price = mysql_result($firstcheck); $price1 = mysql_result($firstcheck1); $price2 = mysql_result($firstcheck2); $price3 = mysql_result($firstcheck3); if ($_POST['radio']) } elseif ($costs <= $result->money) { } if ($to != $result->city) { Need some general help and pointers please im pretty new you see Quote Link to comment https://forums.phpfreaks.com/topic/138602-undefined-variablesratios-few-small-errors/ Share on other sites More sharing options...
JasonLewis Posted December 28, 2008 Share Posted December 28, 2008 Take a look at mysql_result in the manual, you're missing 2 parameters. Try making all your mysql_result calls this: $price = mysql_result($firstcheck, 0, 'ticketprice'); Actually, you don't need ticketprice, so only put the 0 there. Quote Link to comment https://forums.phpfreaks.com/topic/138602-undefined-variablesratios-few-small-errors/#findComment-724709 Share on other sites More sharing options...
MadTechie Posted December 28, 2008 Share Posted December 28, 2008 Warning: Wrong parameter count for mysql_result() in /home/djwdesi/public_html/gangster/airport.php on line 37 Warning: Wrong parameter count for mysql_result() in /home/djwdesi/public_html/gangster/airport.php on line 38 Warning: Wrong parameter count for mysql_result() in /home/djwdesi/public_html/gangster/airport.php on line 39 Warning: Wrong parameter count for mysql_result() in /home/djwdesi/public_html/gangster/airport.php on line 40 All lines above i am going to guess your not connecting to the database first.. to check try this $secondcheck = mysql_query($firstcheck) or die(mysql_error()); Notice: Undefined index: radio in /home/djwdesi/public_html/gangster/airport.php on line 44 if ($_POST['radio']) to if (isset($_POST['radio'])) Notice: Trying to get property of non-object in /home/djwdesi/public_html/gangster/airport.php on line 76 see 83 Notice: Undefined variable: costs in /home/djwdesi/public_html/gangster/airport.php on line 76 $cost =0; //<---Add cost here so its set $to =0; //<---Add cost here so its set if (isset($_POST['radio'])) Notice: Trying to get property of non-object in /home/djwdesi/public_html/gangster/airport.php on line 83 This is also to do with the SQL problem $sql = "SELECT location_id FROM user_stats WHERE user_id='$id'"; to $sql = "SELECT * FROM user_stats WHERE user_id='$id'"; Notice: Undefined variable: to in /home/djwdesi/public_html/gangster/airport.php on line 83 see line 76 correction Last error you probably haven't go to yet is $flightcosts = $sql->money - $costs; should be $flightcosts = $result->money - $costs; Quote Link to comment https://forums.phpfreaks.com/topic/138602-undefined-variablesratios-few-small-errors/#findComment-724714 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.