Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by kingb00zer

  1. hey guys im curently writing some code that requires a variable $count to match id numbers which I have set in my tables as auto increment. the problem is that snce testing out many diferent things and deleting accounts i now how have the problem being that each sign up counts the increment to 26 when in total there is only 7 accounts. i want to delete all of these accounts which i made for testing and have all the auto incrememnting start again from 1 again. how would I do that without recreating each individual table?
  2. THIS PROBLEM HAS BEEN SOLVED! all I needed to do was copy the entire code from the page I was viewing and wanting the results on and echo it out after the script run with a minor change to one area where I had the results displayed. hey i have a form that creates and updates a bunch of information in a database, this form and its scripts work fine I just want to know how I can take some fo the variables created in the form that processes all of the information and display it on the same page afte the form has been processed.for example if in this script it finds me 7 apples ($apple), 3 bananas ($banana), and 9 oranges ($orange). how would I take these 3 variables so that after the script is run i header to the same page and then display?:"You went out and found $apple apples , $banana bananas and $orange oranges"
  3. Thanks I gave it a try and well i couldnt get to see if ti worked lol, this is kind of embarrasing I leared where I'm about to ask where I went wrong at school just last year. I changed the entire file so that it is php with html embedded in echo's and now I'm getting a "syntax error, unexpected $end" on line 38 which is the ?> line. I bet it is something small lol. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><?php session_start(); echo "<html>";echo "<head> <link rel='stylesheet' type='text/css' href='gamestyles.css' /> </head>";echo "<title> array, session and database test. </title>";echo "<body bgcolor='black'>"; $user=mysql_query("SELECT username FROM users WHERE username='" . $_SESSION['username'] . "'");while($row = mysql_fetch_array($user)) { $username=$row['username'];$pass=mysql_query("SELECT password FROM users WHERE username='" . $_SESSION['username'] . "'");while($row = mysql_fetch_array($pass)) { $password=$row['password'];$mail=mysql_query("SELECT email FROM users WHERE username='" . $_SESSION['username'] . "'");while($row = mysql_fetch_array($mail)) { $email=$row['email']; } echo "<h1 align='center' class='one'> Welcome. </h1>";echo "<table class='mainpage' width='240px'>";echo "<tr><td class='two' align='left'>Your username is: $username </td></tr>";echo "<tr><td class='two' align='left'>Your password is: $password </td></tr>";echo "<tr><td class='two' align='left'>Your email is: $email </td></tr></table>";echo "</body>"; echo "</html>";?>
  4. Hi I have recently got to the point in a site im making where I can log in the next step has got me really confused. See what I want to do is after I log in I just want to see a page which says welcome, this is your username, this si your password and this is your email adress. But I want to retrieve that data from the table in the database which stores that information. The table in the database called "users" has the following rows: id (which is auto increment & indexed), username, password and email. I understand I need to use an array and possibaly a loop to get that information but I am also needing to use some kind of session related code to retrieve that users username, password and email which is the part that has me confused. This is what I have so far <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><?php session_start(); ?><html><head><link rel="stylesheet" type="text/css" href="gamestyles.css" /> </head><title> array, session and database test.</title> <body bgcolor="black"> <?php // need to figure out what to put after WHERE in order to pinpoint the data in the database that matches the user in this session $user=mysql_query("SELECT username FROM users WHERE");while($row = mysql_fetch_array($user)) { $username=$row['username'];$pass=mysql_query("SELECT password FROM users WHERE");while($row = mysql_fetch_array($pass)) { $password=$row['password'];$mail=mysql_query("SELECT email FROM users WHERE");while($row = mysql_fetch_array($mail)) { $email=$row['email']; } ?> <h1 align="center" class="one"> Welcome. </h1> <table class="mainpage" width="240px"> <tr><td class="two" align="left"> Your username is: $username </td></tr> <tr><td class="two" align="left"> Your password is: $password </td></tr> <tr><td class="two" align="left"> Your email is: $email </td></tr> </table> </body> </html> just a note, I am aware that bgcolor is depreciated i just havnt got aroudn to add it to style sheet. Also there are 3 variables in the html table that I havn't got within php tags yet thats not a problem I still have to echo out the table I jst wanted to get this question off before i go to bed. thank you
  5. Hey I am looking for an online host that supports cron jobs at a decent price range. I recently made a noob mistake and paid for 1 year with crazydomains.com only to find that it doesnt supprt cron jobs, now im 90 dollars poorer than I already was.
  6. thank you How should I go about using an alternative for session_register() And session_is_registered()?and as for bgcolor i have been meaning to set up a style for body in my style sheet, just been a bit lazy on that lol.
  7. Hey I have recently completed sign up and log in forms for a site I am working on and now that I can log in I am wondering weather I have to start session on every page viewable after logging in or if the session stays connected as I surf through the pages.I have provided what code I used to log in below in case you need to see it.check login.php <?phpinclude("connection.php");$username= $_POST['username'];$password= $_POST['password'];// check if username and passwords match$checkuser= "SELECT * FROM users WHERE username = '$username' and password = '$password'";$result=mysql_query($checkuser);$count=mysql_num_rows($result);if ($count == 1){session_register("username");session_register("password");header("location:login_success.php");}else {echo "Wrong Username or Password";}?> login_sucess.php <?session_start();if(!session_is_registered($username)){header("location:welcome.php");}?> welcome.php <html><head><link rel="stylesheet" type="text/css" href="gamestyles.css" /> </head><title> the site</title> <body bgcolor="black"> <h1 align="center" class="one"> Welcome to the site </h1> <h1 align="center" class="one"> <a href="drugmarket.html"> CLICK HERE TO ENTER</a> </h1> </body> </html> Basically asking if I need to add any php session code to welcome.php and of course the pages viewable in the rest of the members only area.
  8. Its all good now, I found my xp disc and xampp is running smooth. however I cant find schedueled tasks to do cron jobs.
  9. Didnt work. Im just going to ahve to re install trustworthy old linux and see if I can get LAMP to work for me.
  10. it gives me an error that says ERROR: status check failure [3]this program must be run form your xampp root directory.not sure what it means.I re installed it and now i just get WARNING: Directory missmatch.
  11. So I tried to run xampp in my windows 7 and I even downloaded what im sure was a windows 7 version of xampp, but it doesnt connect to either apache or sql. I have been trying to find my old xp install disc but it is no where to be found yet, so I need some kind of an alternative to xampp that is gaurenteed to work with windows 7. Any suggestions?
  12. Hey just a quick question about cron jobs. Do I need to have an online server to use them or can I use a program with xamp for the testing stages before it is ready for online hosting?
  13. I need them to run 24 hrs a day for the duration of the round, which will last for 1 month. so for example every hour and at 10 past, 20 past, 30 past, 40 past and 50 past the hour i want a script to run producing 5 added turns to everyones account. These cron jobs sound like what I need.
  14. Hi guys I have been studdying a bit of php over the last year and at the moment am trying to create a little game. now I have no problem writing a script that creates an action and updates a database which is mostly what a game like this is made up of. But for a game like this to work I need to create a script that every so often adds a number to the everyones account to give them "turns" to spend in the game, as well as other automated actions that happen in the game. I just dont know where to start. If somebody could give me a little nudge in the right direction here that would be great. if you would like me to elaborate more please ask. thank you.
  15. Thank yuo to everyone who helped me with this, it now works... oh it feels so good that moment when somehting that has bugged you for days instanly stops bugging you
  16. this is the form code<form method="post" action="roundsignup.php"><u>Name your Soldiers. All will have the same name but be numbered</u> <br /> Name your Soldiers: <input type="text" size="15" maxlength="20" name="soldier" /> <br /> <input type="submit" value="Create Gang Members" /> </form> I noticed that i placed the method="post" in the input tag then corrected it and placed it into the form tag. Now I dont get any errors but it still fails to put the soldier name into the database.below is the code for the roundsignup.php incase it makes it easier to figure out my problem <?php error_reporting(E_ALL); ini_set('display_errors', 1); include('connection.php');$soldiergstat1= "INSERT INTO gamestats WHERE user='$_POST[username]' (soldier) VALUES ('$_POST[soldier]01')";$resultgstat1=mysql_query($soldiergstat1);$soldiercstat1= "INSERT INTO charactorstats WHERE user='$_POST[username]' (soldier) VALUES ('$_POST[soldier]01')";$resultcstat1=mysql_query($soldiercstat1);echo ("Thank you your gang has been created succesfully.");?>
  17. Ok I figured it out using an old registration form, well when i said figured out I mean i have what i want but i still dont understand why it wasnt working on the other script. I thoght id paste the code I used to get it to work which is just my master account registration script made to add a second account and number each account01 then account02 in the users row. so my guess is maybe something wrong with the php myadmin side of things in my gamestats table. <?php error_reporting(E_ALL); ini_set('display_errors', 1); include('connection.php');//check for duplicate names$query= "SELECT * FROM users WHERE username='$_POST[username]'";$result= mysql_query($query);$num= mysql_num_rows($result);if ($num == 0) {//check for duplicate emails$query2= "SELECT * FROM users WHERE email='$_POST[email]'";$result2= mysql_query($query2);$num2= mysql_num_rows($result2);if ($num2 == 0) {//check if password and email confirmation is the sameif (($_POST['pass'] == $_POST['pass2'] && $_POST['email'] == $_POST['email2'])) {// insert into users table$sql2= "INSERT INTO users (username, email, password) VALUES ('$_POST[username]01', '$_POST[email]', '$_POST[pass]')";$result2=mysql_query($sql2);$sql15= "INSERT INTO users (username, email, password) VALUES ('$_POST[username]02', '$_POST[email]', '$_POST[pass]')";$result15=mysql_query($sql15);echo ("Thank you your master account has been created succesfully.");}else{echo ("error signing up, please ensure that everything you have entered is correct.");}}}?> hopefully this helps pinpoint the issue I had with the previous scriptEDIT: ok it is definately the gamestats table it just isnt putting any data into it (I'm messing around and trying diferent things with my master account registration script)
  18. hmmm cant seem to get it to work, same error appearing, so I decided to just try to add the one entry instead of 3.. just off this scripts topic id liek to mention that the $_post[soldier]01 liek I orginaly did actually did work when i trialed it on the master account sign up page... maybe its my html or possible a php myadmin issue either way it has got me baffled... ill keep working on this and fingers crossed i dont come abck in a couple of house to bug you guys again heh..p.s. please excuse my typos i type quicker than I probably should
  19. thanks synook, now I know roughly where to make corrections, but as for the sql injection i had not added it yet but I will take the code from the master account registration form part and apply it when this part is complete.also if you are reffering to the numbering at the end of the $_POST[soldier]01 I tested this with my master account registration form and it worked fine.
  20. OK so I have decided to leave out the part where it checks for other accounts of the same name, I can do that later. I really want to figure out how to insert multiple entries into 1 table (the 2nd table I will add at a later stage). I also found a mistake in the first block of code that I posted in this thread at the insert into (soldier, ) part I had it written as soldiers but that is fixed and still the same error. <?php error_reporting(E_ALL); ini_set('display_errors', 1); include('connection.php');$soldiergstats1= "INSERT INTO gamestats (soldier, turns, money, thugs, dealers, hoes, coke, heroin, weed, xtc, ketamine, pistols, shotguns, ak47s, suvs) VALUES ('$_POST[soldier]01', '10000', '2000', '200', '50', '50', '0', '0', '0', '0', '0', '50', '0', '0')";$sgstatresult1=mysql_query($soldiergstats1);$soldiergstats2= "INSERT INTO gamestats (soldier, turns, money, thugs, dealers, hoes, coke, heroin, weed, xtc, ketamine, pistols, shotguns, ak47s, suvs) VALUES ('$_POST[soldier]02', '10000', '2000', '200', '50', '50', '0', '0', '0', '0', '0', '50', '0', '0')";$sgstatresult2=mysql_query($soldiergstats2);$soldiergstats3= "INSERT INTO gamestats (soldier, turns, money, thugs, dealers, hoes, coke, heroin, weed, xtc, ketamine, pistols, shotguns, ak47s, suvs) VALUES ('$_POST[soldier]03', '10000', '2000', '200', '50', '50', '0', '0', '0', '0', '0', '50', '0', '0')";$sgstatresult3=mysql_query($soldiergstats3);echo ("Thank you your gang has been created succesfully.");?> Notice: Undefined index: soldier in /home/schulzy/public_html/roundsignup.php on line 8Notice: Undefined index: soldier in /home/schulzy/public_html/roundsignup.php on line 11Notice: Undefined index: soldier in /home/schulzy/public_html/roundsignup.php on line 14any ideas? anybody??
  21. ok I fixed that spelling mistake and I still get the same error
  22. hi I am attempting to make a registration form which creates up to 20 accounts in one go below I just used 3 to try and get it right and save myself sometime until i got it right. I already have a registration form which works but that is for the making a master account. and I used the same code, just altered to be for a diferent table with diferent feilds in it to the master account registraion form. now I seem to be getting these errors when i test it and now I am out of ideas, any clues?EDIT: I havnt actually shown when I tried to enter into both tables however the second table charactorstats was getting the same errors as game stats, i should ahve thought when titling this thread lol....Errors:Notice: Undefined index: soldier in /home/schulzy/public_html/roundsignup.php on line 8Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/schulzy/public_html/roundsignup.php on line 10Notice: Undefined index: soldier in /home/schulzy/public_html/roundsignup.php on line 14Notice: Undefined index: soldier in /home/schulzy/public_html/roundsignup.php on line 17Notice: Undefined index: soldier in /home/schulzy/public_html/roundsignup.php on line 20Thank you your gang has been created succesfully. <<< this sint actually an error it is an echo for if everything is true and the registration went through. log in form (html)<html><body><p align="center"> <b>register to round</b></p><table align="center"><tr><td> <form action="roundsignup.php">Name your Soldiers. All will have the same name but be numbered <br />Soldiers: <input type="text" length="20 method="post" name="soldier" id="soldier" /> <br /> <input type="submit" value="Create Gang Members" /></td></tr></form></table></body></html> roundsignup.php<?php error_reporting(E_ALL); ini_set('display_errors', 1); include('connection.php');//check for duplicate names$query1= "SELECT * FROM users WHERE solider='$_POST[soldier]'";$result1= mysql_query($query1);$num1= mysql_num_rows($result1);if ($num1 == 0) {$soldiergstats1= "INSERT INTO gamestats (soldiers, turns, money, thugs, dealers, hoes, coke, heroin, weed, xtc, ketamine, pistols, shotguns, ak47s, suvs) VALUES ('$_POST[soldier]01', '10000', '2000', '200', '50', '50', '0', '0', '0', '0', '0', '50', '0', '0')";$sgstatresult1=mysql_query($soldiergstats1);$soldiergstats2= "INSERT INTO gamestats (soldiers, turns, money, thugs, dealers, hoes, coke, heroin, weed, xtc, ketamine, pistols, shotguns, ak47s, suvs) VALUES ('$_POST[soldier]02', '10000', '2000', '200', '50', '50', '0', '0', '0', '0', '0', '50', '0', '0')";$sgstatresult2=mysql_query($soldiergstats2);$soldiergstats3= "INSERT INTO gamestats (soldiers, turns, money, thugs, dealers, hoes, coke, heroin, weed, xtc, ketamine, pistols, shotguns, ak47s, suvs) VALUES ('$_POST[soldier]03', '10000', '2000', '200', '50', '50', '0', '0', '0', '0', '0', '50', '0', '0')";$sgstatresult3=mysql_query($soldiergstats3);echo ("Thank you your gang has been created succesfully.");}else{echo ("Sorry but that account name is in use.");}?> every feild in that gamestats table exists and the soldier feild has also been set as index thru php myadmin. also the part where it says '$_POSTsoldier]01' and 02 and 03 were just done as a test to see if I could number each account individually like that. Even with out the numbers I still got the same errors, also can I number accounts like that so to save people time when filling out the form? oh and btw I also had a form with 20 text inputs and attempted to insert the same stuff and got the same errors again just way more of them lol.
  23. oh lol I see the typo, funny enough that isnt the one that is causing me the trouble it is the gap between the first and second one in the 2nd formEDIT: ok I put the form tag within before the </tr> lol i dont know how i made that happen lol. and fixed that typo code below <table class="defend" align="left"> <tr><td align="center"> <form> <b>Current target:</b> <input type="text" size="20" /> </td> </form> </tr> <tr><td align="center"> <b> Target List </b> </td> </tr> <tr><td align="center"> <form> <input type="text" size="20" /> </td> </tr> <tr><td align="center"> <input type="text" size="20" /> </td> </tr> <tr><td align="center"> <input type="text" size="20" /> </td> </tr> <tr><td align="center"> <input type="text" size="20" /> </td> </tr> <tr><td align="center"> <input type="text" size="20" /> </td> </tr> </form> </table> These text inputs are just for show at this stage.EDIT: oh crap i just reallised i had the 2nd form close tag outside the tr also lol im gonig to bed... cheers guys
  • Create New...