tom2oo8 Posted October 31, 2008 Share Posted October 31, 2008 As you may know im new to php (learnt by looking at a few scripts) i started writing my game yesterday without any prior knowlege to php and im getting more errors and i dont have a clue why? I get this error Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /home/a7212264/public_html/hideoutbuy.php on line 175 <? session_start(); if($_SESSION['loggedin']==0) { header("Location:index.php");exit; } include "Database.php"; global $conn; $userid=$_SESSION['id']; $musername=$_SESSION['username']; $id=$_GET['proid']; $quant=$_GET['quant']; $1=msql_query("SELECT money FROM users WHERE username='$musername'"); $2=msql_query("SELECT price FROM items WHERE id='$proid'"); $3=msql_query("SELECT name FROM items WHERE id='$proid'"); $4=msql_query("SELECT id FROM users WHERE username='$username'"); $res1=mysql_fetch_array($1); $res2=mysql_fetch_array($2); $res3=mysql_fetch_array($3); $name=$res3['name'] if ($res1['money'] < $res2['price']*$quant) { print "You don't have enough money to buy the house: {$res3['name']}"; print "please go back using the links at the side."; exit; } else { $res4=mysql_fetch_array($4); $uid=$res4['id']; $5=msql_query("SELECT defence FROM items WHERE id='$proid'"); $res5=mysql_fetch_array($5); $defence=$res4['defence']; print "You brought the object: {$res3['name']}"; print "Your account balance has gone down by {$res2['price']}"; mysql_query("UPDATE users SET hideout='$name' WHERE id='$uid'"); mysql_query("UPDATE users SET totaldefence='$defence' WHERE id='$uid'"); mysql_query("UPDATE users SET money=money-'$price'*'$quant' WHERE id='$uid'"); } ?> line 175 is $1=msql_query("SELECT money FROM users WHERE username='$musername'"); PHP version 5.2.* MySQL ver. 5.0.45-community Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/ Share on other sites More sharing options...
jwilliam Posted October 31, 2008 Share Posted October 31, 2008 You can't begin php variables with numbers. Instead of $1 use something like $var_1. Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-679715 Share on other sites More sharing options...
tom2oo8 Posted October 31, 2008 Author Share Posted October 31, 2008 You can't begin php variables with numbers. Instead of $1 use something like $var_1. Thanks Ill try it ok i changed them all lol more errors Parse error: syntax error, unexpected T_IF in /home/a7212264/public_html/hideoutbuy.php on line 183 line 183 is if ($res1['money'] < $res2['price']*$quant) Sorry for me being noob at php. Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-679720 Share on other sites More sharing options...
revraz Posted October 31, 2008 Share Posted October 31, 2008 post a few lines of code above and below that line Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-679727 Share on other sites More sharing options...
tom2oo8 Posted October 31, 2008 Author Share Posted October 31, 2008 post a few lines of code above and below that line $res3=mysql_fetch_array($3); $name=$res3['name'] if ($res1['money'] < $res2['price']*$quant) { print "You don't have enough money to buy the house: {$res3['name']}"; print "please go back using the links at the side."; exit; Hope that helpss Thanks Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-679730 Share on other sites More sharing options...
Flames Posted October 31, 2008 Share Posted October 31, 2008 your missing a ; replace $name=$res3['name'] with $name=$res3['name']; if you ever want a coder for your game send me a pm Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-679736 Share on other sites More sharing options...
tom2oo8 Posted November 1, 2008 Author Share Posted November 1, 2008 your missing a ; replace $name=$res3['name'] with $name=$res3['name']; if you ever want a coder for your game send me a pm Cool Thanks For free lol? Im 14 and has no money lol, now you know my age feel free to take back that offer XD Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-679755 Share on other sites More sharing options...
tom2oo8 Posted November 1, 2008 Author Share Posted November 1, 2008 ooo :S Fatal error: Call to undefined function msql_query() in /home/a7212264/public_html/hideoutbuy.php on line 175 Thats the same line as before :S but i remember from last time that that means that its either not in database or $musername is wrong???Not sure :S Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0 Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-679756 Share on other sites More sharing options...
xtopolis Posted November 1, 2008 Share Posted November 1, 2008 Call to undefined function msql_query() msql ? come on now, that's an easy one. Read it carefully. Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-679760 Share on other sites More sharing options...
tom2oo8 Posted November 1, 2008 Author Share Posted November 1, 2008 Call to undefined function msql_query() msql ? come on now, that's an easy one. Read it carefully. Lool Sorryy XD Next time ill read through carefully XD Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-679762 Share on other sites More sharing options...
tom2oo8 Posted November 1, 2008 Author Share Posted November 1, 2008 cant edit posts??? but somthing really wierd just happened... None of my data is show upany more eg my register page dont work anymore login works but it has errors now, ive checked my database connect file but its not it ???? Well Thanks all for your help. Ive got to go bed now :| Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-679770 Share on other sites More sharing options...
Flames Posted November 1, 2008 Share Posted November 1, 2008 im also 14, and yes for free. And we can't help without the code and or error itself. you should set this as unsolved. Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-680022 Share on other sites More sharing options...
tom2oo8 Posted November 1, 2008 Author Share Posted November 1, 2008 im also 14, and yes for free. And we can't help without the code and or error itself. you should set this as unsolved. cool Nice, Itd be great if you could help .... Just to point out, My site is completly dogey lol, Thats why im trying fix loads. And the register page dont search if the users taken XD , Had no clue how i was to do that, i do now . Thats why your help would be great. Ill message you with whats the game like and all the ftp passwords and that , If you want them... Also the error is The games a pimp game btw also the site layout is S*** im fixing now, site name is nightkillas.com Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-680098 Share on other sites More sharing options...
Flames Posted November 1, 2008 Share Posted November 1, 2008 what you mean by pimp game, and whats the login so i can see what its like Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-680110 Share on other sites More sharing options...
tom2oo8 Posted November 1, 2008 Author Share Posted November 1, 2008 what you mean by pimp game, and whats the login so i can see what its like Lol well the login brok after i tried to make it so it was all on one page XD <?php session_start(); include "Database.php"; $page=$_GET['page']; if($page=register){ print " <form method='post' action='index.php?page=register2'> Username: <input type='password' name='username'> <p> </p> Password: <input type='password' name='password'><p> </p> <input type='submit' value='register'> </form> " } if($page=register2) { $table=users $check = "select id from $table where username = '".$_POST['username']."';"; $qry = mysql_query($check) or die ("Could not match data because ".mysql_error()); $num_rows = mysql_num_rows($qry); if ($num_rows != 0) { echo "Sorry, there the username $username is already taken.<br>"; echo "<a href=index.php?page=register>Try again</a>"; exit; } else { $insert = mysql_query("insert into $table values ('NULL', '".$_POST['username']."', '".$_POST['password']."')") or die("Could not insert data because ".mysql_error()); echo "Your user account has been created!<br>"; echo "Now you can <a href=index.php?page=login>log in</a>"; } if($page=login) { print " Login here <form method='post' action='index.php?page=login2'> Username: <input type='password' name='username'> <p> </p> Password: <input type='password' name='password'><p> </p> <input type='submit' value='login'> </form> " } if($page=login2) { ob_start(); $myusername=$_POST['username']; $mypassword=$_POST['password']; $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM users WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ session_register("username"); session_register("password"); header("location:index.php?page=logindone"); } else { echo "Wrong Username or Password"; } ob_end_flush(); } if($page=logindone) { global $conn; if($_SESSION['loggedin']==0) { header("Location:index.php");exit; } $userid=$_SESSION['id']; $username=$_SESSION['username']; $uq=mysql_query("SELECT attacks FROM users WHERE username='$username'") or die(mysql_error()); $attacks=mysql_fetch_array($uq); print "<h1>You have logged on, {$username}! You have {$attacks['attacks']} attacks at the moment.</h1>" } if($page=hideouts) print "You can buy any of these wonderful places to stay in , You can only have 1 at a time though. <style type='text/css'> <!-- .style3 { font-size: 18px; color: #FF0000; font-weight: bold; } .style4 { color: #FF0000; font-size: 14px; } .style5 { color: #FF0000; font-weight: bold; } .style7 {color: #FF0000} --> </style> <table width='339' height='506' border='1' cellpadding='0'> <tr> <td width='174' height='139' valign='top'><p class='style3'>Shack</p> <p class='style4'>price $0</p> <span class='style4'>Defence 100 </span> <form name='form1' method='post' action='index.php?page=hideoutbuy1&proid=1&quant=1'> <label> <input type='submit' name='button' id='button' value='Submit'> </label> </form> <p class='style4'> </p></td> <td width='153'><span class='style4'><img src='images/Shack.jpg' width='150' height='100' border='0' usemap='#Map'></span> <map name='Map'> <area shape='rect' coords='69,60,116,63' href='#'> </map> </td> </tr> <tr> <td height='160' valign='top'><p class='style5'>Trailer</p> <p class='style7'>price $5000 </p> <p class='style7'>defence 300</p> <form name='form2' method='post' action='index.php?page=hideoutbuy1&proid=2&quant=1'> <label> <input type='submit' name='button2' id='button2' value='Submit'> </label> </form> <p class='style7'> </p></td> <td><img src='images/Trailer.jpg' width='150' height='100'></td> </tr> <tr> <td valign='top'><p class='style5'>Appartment</p> <p class='style4'>Price $10000</p> <p class='style4'>Defence 600</p> <form name='form3' method='post' action='index.php?page=hideoutbuy1&proid=3&quant=1'> <label> <input type='submit' name='button3' id='button3' value='Submit'> </label> </form> <p> </p> <p class='style4'> </p></td> <td><img src='images/Apartment.jpg' width='150' height='100'></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> " } Not finished yet btw Parse error: syntax error, unexpected '}' in /home/a7212264/public_html/index.php on line 43 line 43 is just " } The pimp game is like you pimp celebs attack people and that .. you get drugs to get celebs and that Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-680155 Share on other sites More sharing options...
corbin Posted November 1, 2008 Share Posted November 1, 2008 Looks to me like you should learn PHP. Not learn it from premade scripts, but actually read some tutorials/articles and learn it. Not read it. I can read Latin outloud without understanding a word of it, but that does me no good. Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-680192 Share on other sites More sharing options...
tom2oo8 Posted November 1, 2008 Author Share Posted November 1, 2008 ye, Iknow why my scripts almost never work... i always forget ; at the end of lnes Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-680196 Share on other sites More sharing options...
Flames Posted November 2, 2008 Share Posted November 2, 2008 the game doesnt really appeal to me, sorry. Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-680491 Share on other sites More sharing options...
tom2oo8 Posted November 2, 2008 Author Share Posted November 2, 2008 the game doesnt really appeal to me, sorry. ok dw about it , thanks for the offer at first though Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-680492 Share on other sites More sharing options...
Acs Posted November 2, 2008 Share Posted November 2, 2008 Start by learning php like corbin said. Trying to create a game is hard. Trying to create a game in a language you don't really understand is practically impossible. Many of the errors you reported here are really newbie errors, and as you said you are a newbie so start by doing newbie stuff and not a game. Try creating a game a few years from now, when you are really comfortable with php and javascript. Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-680493 Share on other sites More sharing options...
tom2oo8 Posted November 2, 2008 Author Share Posted November 2, 2008 Start by learning php like corbin said. Trying to create a game is hard. Trying to create a game in a language you don't really understand is practically impossible. Many of the errors you reported here are really newbie errors, and as you said you are a newbie so start by doing newbie stuff and not a game. Try creating a game a few years from now, when you are really comfortable with php and javascript. Yer true but when i read stuff like that i give up, Same happened with c++ i learnt it and could make programs but when the book told me diffrent ways of doing it to what i normally did it made me cnfused and annoyed and extreemly bored. ive actually suprisingly nearly finished my game and so far it works so im quite happy about that Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-680501 Share on other sites More sharing options...
tom2oo8 Posted November 2, 2008 Author Share Posted November 2, 2008 errrrrrrggggg ffs 000webhost dont allow index.php?page=register and that it redirects to page not found and / or laggs the site . Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-680513 Share on other sites More sharing options...
Flames Posted November 2, 2008 Share Posted November 2, 2008 thats your error not theres, i've had around 5 sites on 000webhost, and if the page exists it exists, also maybe put a custom nor found page (404 error page) cause theres is horrible. Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-680529 Share on other sites More sharing options...
tom2oo8 Posted November 2, 2008 Author Share Posted November 2, 2008 thats your error not theres, i've had around 5 sites on 000webhost, and if the page exists it exists, also maybe put a custom nor found page (404 error page) cause theres is horrible. i mean index.php?page=dgfjag dont work and comes up with error on there site but when i go to /index.php it works? Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-680540 Share on other sites More sharing options...
Flames Posted November 2, 2008 Share Posted November 2, 2008 index page code? Quote Link to comment https://forums.phpfreaks.com/topic/130936-solved-hmmm-more-game-help/#findComment-680544 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.