Jump to content

mattd8752

Members
  • Posts

    251
  • Joined

  • Last visited

    Never

Everything posted by mattd8752

  1. Forgot to mention, if I add another car they will both have 11 as their carid and both have the 11th car.
  2. I know, I guess I didn't think of that but, That isn't the problem though.  The problem is getting the IDs from the database.  I always get 11 from the car part.
  3. Im just curious if anyone knows, would it work if I made the car select a second page?  If so, or you can think of any "rebuilds" to fix this please tell me.
  4. Ouch, You should add a warning sign to that link here for people on Dial Up, Im not but it still lagged my connection for almost a minute.  Anyway, you would probably just want to use Header: http://youarebanned.com or whatever the url is.  You don't need a script like that except for a reffer system.
  5. Well, learn.  If you don't want to pay there aren't many free options available for this (unfortunately).  You may be able to freelance someone here who knows C as well to program you a  system for a 1 time fee of much less than 700$, but there are risks when dealing with individuals.
  6. Well, Im not positive, but I believe that PHP is misinterpreting what I am telling it to do.  I don't quite get how, but I'll show you a bit of code and what it is supposed to do: [code] $usrid = 0; $sql = "SELECT * FROM userdata"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)){   $currid = $row['id'];   if($usrid < $currid){   $usrid = $currid;   } } $usrid = $usrid + "1"; $carid = 0; $sql = "SELECT * FROM userdata"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)){   if($carid < $row['carid']){   $carid = $row['carid'];   } } $carid = $carid + "1"; $sql = "SELECT * FROM salecars"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)){   if($carid = $row['carid']){   $carname = $row['name'];   if($row['type'] != "beginner"){   echo "Stop trying to cheat.</div><div id=\"footer\"><b>".$onlinet."</b></div>";   die();   }   } } mysql_query("INSERT INTO userdata (id,owner,cash,carid) VALUES ('".$usrid."','".$userdata['username']."','10000', '".$carid."')");echo mysql_error(); mysql_query("INSERT INTO car (carid,name,owner) VALUES ('".$carid."','".$carname."','".$userdata['username']."')");echo mysql_error(); [/code] That code basically assigns IDs to be inserted into the database.  I am getting their UserID fine, however when I look in the database, their carid in both the car and userdata database is = 11. If someone could fix this please try.  If you need to see the whole code just ask, but just a warning it has 300 and something lines, and it is a bit messy since I coded it all tonight (without a break from this file).
  7. You can echo $array; but you can't do it for every array.
  8. Well, if I was using your script, just a warning I could use the name .../whatever to be 2 folders back and in whatever folder and tuduh, I can replace your actual sites images with whatever I want.  I had this problem when I did this not to long ago.  I changed my folders to use their ID.
  9. I get the following feedback: thisisatestusernamethisisatestregistrationkeythisisatestpassword540ee6cb238b047b425a326bf5cfdcc3thisisatestemailUsername is available... Unknown column 'thisisatestusername' in 'field list'Your account should be registered. Try logging in! Login Page From my registration script: [code] <?php include "dbconnect.php"; if(!isset($_POST['register']) || !isset($_POST['regkey']) || !isset($_POST['username']) || !isset($_POST['password']) || !isset($_POST['email'])){ ?> <html> <head> <title>Registration Form</title> </head> <body> <form method="POST" action="register.php"> Username:<input type="text" name="username" size="20"><br> Password:<input type="password" name="password" size="20"><br> Email:<input type="text" name="email" size="20"><br> Registration Key:<input type="text" name="regkey" size="20"> (you need to get a registration key to sign up)<br> <input type="submit" value="Submit" name="register"> </form> </body> </html> <?php }else{ //reg them $username = $_POST['username']; echo $username; $key = $_POST['regkey']; echo $key; $pass = $_POST['password']; echo $pass; $pass = md5($pass); echo $pass; $email = $_POST['email']; echo $email; $found = mysql_result(mysql_query('SELECT count(0) FROM `users` WHERE `username` = "'.$username.'" LIMIT 1'), 0, 0); if ( $found > 0 ){ echo ("Sorry, that username is already taken."); die; }else{ echo "Username is available...<br>"; mysql_query("INSERT INTO users (username,password,regkey,email) VALUES(".$username.",".$pass.",".$key.",".$email.")"); echo mysql_error(); echo "Your account should be registered.  Try logging in!  <a href=\"login.php\">Login Page</a>"; } } ?> [/code] It is not placing anything in the database and you can probably see the MYSQL error, that is with me writing thisisatest* for every field and submitting, all the data is taken but none is being put into my database.  My DB connect DOES WORK, I have a working login script with the same DBconnect page.
  10. I'm working with him on this now, User signup is in progress, profiles aren't happening right away (all we need is for the user to exist), teams are going to be after the car system is built, the upgrades, then further stuff.  I am doing formulas for this game, I was actually wondering, what would I do to keep the formulas based on tons of things.  For example I was thinking of calculating the winner by points: so points would = a random between 95 and 100*hp/10+accel and a bit more going into it.
  11. Well, that might take a while aswell.  You have to change the refrences to $_SESSION where it refrences login data, but where it references user input (like forms) definatly leave it as $_POST[''] Anyways, good luck with this.
  12. That fixed about half of the problem, kinda makes me feel dumb, I forgot to link the user to the database.  The D n' D way works now.  But registration doesn't want to add them to the database.  I don't see why this isn't working.  If you can find the error please let me know.  Login doesn't let me go as anyone, it does let me login if I create the data in the database. It also can read if the username is taken, So my guess is I am having the problem with: [code] mysql_query("INSERT INTO users (username, password, regkey, email) VALUES($username, $pass, $key, $email) ");[/code]
  13. I belive PHP would have to do that whenever accessing the script.  But why do that when you can just renumber them based on their array key after retrieving them if you need them to be numbered 0-whatever.  If you insist on this PHP would have to check and keep a var of what is the highest, looping if($maxid > $dbcurrentid){ //incorrect }else{ $maxid = $dbcurrentid; } after the entire loop $newuserid = $maxid + 1
  14. In whichever one is using $_POST just replace that with $_SESSION in every page.  Might take a while but it works.
  15. Ok, I've got my second version of the script here, and its got some MAJOR bugs. I have no idea how I've gotten to these, but: Register.php: [code] <?php include "dbconnect.php"; if(!isset($_POST['register']) || !isset($_POST['regkey']) || !isset($_POST['username']) || !isset($_POST['password']) || !isset($_POST['email'])){ ?> <html> <head> <title>Registration Form</title> </head> <body> <form method="POST" action="register.php"> Username:<input type="text" name="username" size="20"><br> Password:<input type="password" name="password" size="20"><br> Email:<input type="text" name="email" size="20"><br> Registration Key:<input type="text" name="regkey" size="20"> (you need to get a registration key to sign up)<br> <input type="submit" value="Submit" name="register"> </form> </body> </html> <?php }else{ //reg them $username = $_POST['username']; $key = $_POST['regkey']; $pass = $_POST['password']; $pass = md5($pass); $email = $_POST['email']; $found = mysql_result(mysql_query('SELECT count(0) FROM `users` WHERE `username` = "'.$username.'" LIMIT 1'), 0, 0); if ( $found > 0 ){ echo ("Sorry, that username is already taken."); die; }else{ echo "Username is available...<br>"; $pass = md5($_POST['password']); mysql_query("INSERT INTO users (username, password, regkey, email) VALUES($username, $pass, $key, $email) "); echo "Your account should be registered.  Try logging in!  <a href=\"login.php\">Login Page</a>"; } } ?> [/code] It looks like its working on that page, but nothing is added to the DB.  Also the following error: [quote] Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/mattd/public_html/f1/register.php on line 33 [/quote] But wait, thats not it, I've got a problem on my next page (yeah... it sucks). I have the login page allowing me to login as anyone (doesn't that rock... if only I wasn't trying to fix it). [code] <? ob_start(); session_start(); session_destroy(); $message=""; $Login=$_POST['Login']; if(isset($Login)){ $username=$_POST['username']; $md5=md5($_POST['password']); // Connect database include "dbconnect.php"; // Check matching of username and password. $result=mysql_query("select * from users where username='$username'"); if(mysql_num_rows($result)!='0'){ // If match. session_register("username"); header("location:main.php"); exit; }else{ // If not match. $message="The username or password you have entered is incorrect.<br>"; } } ?> <html> <head> <title>Login</title> </head> <body> <? echo $message; ?> <form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>"> <table> <tr> <td>User : </td> <td><input name="username" type="text" id="username" /></td> </tr> <tr> <td>Password : </td> <td><input name="password" type="password" id="password" /></td> </tr> </table> <input name="Login" type="submit" id="Login" value="Login" /> </form> </body> </html> [/code] This code outputs the form first, then no errors if I make up a username and password, but if I use my username and password I get the exact same thing.  The problem is the database isn't being searched.  The problem might be in my dbconnect script, so here it goes (I hope Im not boring you to death) [code] <?php $host="localhost"; // Host name. $db_user="mattd_racing"; // MySQL username. $db_password="HIDDEN"; // MySQL password. $database="mattd_racingdb"; // Database name. mysql_connect($host,$db_user,$db_password); mysql_select_db($database); ?> [/code] There was no error from this reported.  I am hoping you can help me, if you have any suggestions please post them.  And thanks trochia, I didn't think of using the manual.
  16. [quote author=smc link=topic=123423.msg510098#msg510098 date=1169423647] Now I'm not exactly sure what causes the problem but I had this difficulty earlier today and this is what was suggested to me to change it to in order to make it more efficent [code] $found = mysql_result(mysql_query('SELECT count(0) FROM `users` WHERE `username` = "'.$username.'" LIMIT 1'), 0, 0); if ( $found > 0 ){ echo ("Sorry, that username is already taken."); die; } else{ echo "Username is available...<br>"; $pass = md5($_POST['password']); mysql_query("INSERT INTO users (username, password, regkey) VALUES($name, $hp, $username ) "); echo "Your account should be registered.  Try logging in!  <a href=\"login.php\">Login Page</a>"; } } ?> [/code] Some variables might need to be changed to suit your needs [/quote] Now what is the use of count(0), what does it do?  I don't quite get that part.
  17. I get the following error: [quote] Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mattd/public_html/f1/register.php on line 29 Sorry, that username is already taken. [/quote] From the following code: [code] <?php include "dbconnect.php"; if(!isset($_POST['register']) || !isset($_POST['regkey']) || !isset($_POST['username']) || !isset($_POST['password']) || !isset($_POST['email'])){ ?> <html> <head> <title>Registration Form</title> </head> <body> <form method="POST" action="register.php"> Username:<input type="text" name="username" size="20"><br> Password:<input type="password" name="password" size="20"><br> Email:<input type="text" name="email" size="20"> Registration Key:<input type="text" name="regkey" size="20"> (you need to get a registration key to sign up)<br> <input type="submit" value="Submit" name="register"> </form> </body> </html> <?php }else{ //reg them $result=mysql_query("select * from users where username='$username'"); if(mysql_num_rows($result) != "1"){ echo "Sorry, that username is already taken."; }else{ echo "Username is available...<br>"; $pass = md5($_POST['password']); mysql_query("INSERT INTO users (username, password, regkey) VALUES($name, $hp, $username ) "); echo "Your account should be registered.  Try logging in!  <a href=\"login.php\">Login Page</a>"; } } ?> [/code] Please help with this one if you can, I am not quite sure what is causing the error.  Also, that user name is available.  It should say your account has been registered with the error if it were to be working properly how I want it to as well (but the error has to go anyway :D ) anyways, if you know what the problem is please reply. Thanks in advanced -- Matt
  18. Bump, sorry for two, but there hasn't even been a view yet.
  19. More problems:  I can't get this page to finish working.  I've got a final code but it won't finish the purchase action.  The output is: Matt 10000000 mrfg2006@gmail.com Checking if you can purchase this car... after I click a link with the code: [code]<?php //PHP DB connect here session_start(); mysql_connect("localhost", "*****", "*****") or die("There was an error connecting to the mysql server."); mysql_select_db("mattd_rpg"); $username=$_SESSION['username']; $password=$_SESSION['password']; $result=mysql_query("SELECT * FROM accounts WHERE username='$username' AND password='$password'"); if(mysql_num_rows($result) == 0){ die("Sorry, you are not logged in, please login again to continue playing.  If you just signed in your username and/or password may be incorrect"); }else{ $query="select * from accounts"; $rt=mysql_query($query); echo mysql_error(); while($nt=mysql_fetch_array($rt)){ if($nt[username] == $username){ echo $nt['username'].' '.$nt['money'].' '.$nt['email'].'<br>'; } } } $cash = $nt[money]; if(!isset($_GET['buy'])){ $query="SELECT * FROM cars"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Cars:</center></b><br><br>"; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $name=mysql_result($result,$i,"name"); $hp=mysql_result($result,$i,"hp"); $price=mysql_result($result,$i,"price"); echo "ID: <a href=\"purchase.php?buy=" . $id . "\">" . $id . "</a><br>Name:" . $name . "<br>HP:" . $hp . "<br>Sale Price:" . $price . "<br><br>"; $i++; } }else{ //check all the stuff for the car they are buying echo "Checking if you can purchase this car...<br>"; $query="SELECT * FROM cars"; $result=mysql_query($query); $num=mysql_numrows($result); $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $name=mysql_result($result,$i,"name"); $hp=mysql_result($result,$i,"hp"); $price=mysql_result($result,$i,"price"); if($id == $_GET['buy']){ if($cash > $price){ echo "You can afford this veichle...  Attempting to purchase it...<br>"; mysql_query("INSERT INTO o_cars (name, hp, owner) VALUES($name, $hp, $username ) "); } } $i++; } } ?> [/code]
  20. I already got past that part, but this is fixed, thanks for trying to help though.
  21. Ok, I've just ditched that part of code (for now) it will just show a link.  Anyway,I will post back if I have any more problems with this script. And that isn't the problem, as I have echoed $cash and it comes out. Thanks for everyone who tried to help.
  22. Start with a news system, then add a search feature, once you've built the news system it will be much easier for you to understand.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.