Jump to content

Derleek

Members
  • Posts

    297
  • Joined

  • Last visited

    Never

Everything posted by Derleek

  1. see? told ya it was simple been at this all day... i need a break... thanks a bunch
  2. creating a dynamic drop down menu... first time i've attempted it. The array's are loaded from a file. here is all of the code, when i comment out the foreach loop section it runs so i'm guessing its in that area of the code <?php dbConnect('thethrgu_moto'); $query = "SELECT * FROM Racers"; $result = mysql_query($query) or die(mysql_error()); $R_id = array(); $rider = array(); $x=0; while($row = mysql_fetch_array($result)){ $R_id[$x]= $row['number']; $rider[$x]= $row['name']; echo "R_ID: {$R_id[$x]}<br>"; echo "rider: {$rider[$x]}<br>"; $x++; } ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <select name="choices[]"> <option value="null">---</option> <?php foreach($rider as $key => $name) { ?><option value="<?php echo $R_id[$key];?>"><?php echo $name;?></option> <?php}?> </select> <br> <br> i'm sure its simple, i just am not familiar with how to load up a drop down menu with php variables... it seems like it should work to me! (then again... i'm no pro
  3. silly mistake... **note the "<br>" when i set the value of $line... silly me
  4. ok, so i have generated this script to store each line from a file into an array: //retrieves file name and size form the form $fileName = $_FILES['userfile']['name']; $fileSize = $_FILES['userfile']['size']; // open the file and save each line as an array entry in $content $content = file($fileName); // count how many lines in the file $numLines = count($content); //counts how many riders are in the file $numRider = $numLines/4; // loop through all the lines $rstore = array();//array to store the $line variable for ($i = 0; $i < $numLines; $i++) { $line = trim($content[$i])."<br>"; $rstore[$i] = $line; } //declaration of arrays for storage into MySQL $Rname = array(); $Rnum = array(); $Rqual = array(); $Rplace= array(); //loops through and stores rider name, number, qualified, placed into each of the respective arrays with identical key's $slot = 0; for ($i = 0; $i<$numRider; $i++) { $Rname[$i] = $rstore[$slot]; $slot++; $Rnum[$i] = $rstore[$slot]; $slot++; $Rqual[$i] = $rstore[$slot]; $slot++; $Rplace[$i]= $rstore[$slot]; $slot++; } but for some reason it is storing return... so when i output it i get line1 line2 line3 line4 with out entering a carriage return... i thought trim() was used to strip down returns?
  5. So, i'm wondering how to go about reading info from a file and storing it into an array line by line. I'm making a game and want to be able to change the options of it by reading it into a file so the file would look like this... 'option1 option2 option3 option4... etc' and i need to place them into a drop down menu. Here is what i have tried... but i keep gettin really reeeeaaally funk results... $content = file('myfile.txt'); $numLines = count($content); for ($i = 0; $i < $numLines; $i++) { $line = trim($content[$i]); echo $line[$i]; } but when i input the file that contains the text: 'option1 option2 option3 option4 etc' I only get out 'opti' for the echo... i'm probably not understanding how the file is stored in the array correctly... i duno
  6. i read that the serialize function kindof defeats the purpose of using a database, seeing is how it hinders the ability to search and access the data directly. i need to learn more about implode i think.
  7. hey, while i'm on the subject. Is there an easy one line command to store an array into a MySQL database w/o using a for loop?
  8. wow really? interesting... didn't know you could do that! guess i'll have to add my sanity check script to it. could you show me how your 'firebug' script works? that intrigues me
  9. if the input is a drop down menu how can they send what they want? it seems pretty set and predictable... thanks for the solution by the way
  10. well the way i am setting the DB up (yes its mysql), there's a drop down menu so everything is closed, don't have to do much scrubbing. i'm not being clear enough here. i need to store 10 sets of values, these will be the 10 different choices of a user. Along with the value of each selection, i need to store the user id, and the order in which it was chosen along with several other variables(which aren't really relevant). I was wondering how to go about storing these 10 choices (in order). I tried doing a for loop with the form below but... here is the form: <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <select name="choices1"> <option value="null">---</option> <option value="rider1">Rider1</option> <option value="rider2">Rider2</option> <option value="rider3">Rider3</option> <option value="rider4">Rider4</option> <option value="rider5">Rider5</option> <option value="rider6">Rider6</option> <option value="rider7">Rider7</option> <option value="rider8">Rider8</option> <option value="rider9">Rider9</option> <option value="rider10">Rider10</option> </select> <br> <br> <select name="choices2"> <option value="null">---</option> <option value="rider1">Rider1</option> <option value="rider2">Rider2</option> <option value="rider3">Rider3</option> <option value="rider4">Rider4</option> <option value="rider5">Rider5</option> <option value="rider6">Rider6</option> <option value="rider7">Rider7</option> <option value="rider8">Rider8</option> <option value="rider9">Rider9</option> <option value="rider10">Rider10</option> </select> <br> <br> now, i saw somewhere that you can do it like this... <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <select name="/*change here*/CHOICES[]"> <option value="null">---</option> <option value="rider1">Rider1</option> <option value="rider2">Rider2</option> <option value="rider3">Rider3</option> <option value="rider4">Rider4</option> <option value="rider5">Rider5</option> <option value="rider6">Rider6</option> <option value="rider7">Rider7</option> <option value="rider8">Rider8</option> <option value="rider9">Rider9</option> <option value="rider10">Rider10</option> </select> <br> <br> <select name="choices[]"> <option value="null">---</option> <option value="rider1">Rider1</option> <option value="rider2">Rider2</option> <option value="rider3">Rider3</option> <option value="rider4">Rider4</option> <option value="rider5">Rider5</option> <option value="rider6">Rider6</option> <option value="rider7">Rider7</option> <option value="rider8">Rider8</option> <option value="rider9">Rider9</option> <option value="rider10">Rider10</option> </select> <br> <br> but i can't figure out how to access the form using that method. when i do: for($i=1;$i<=10;$i++) { echo "CHOICE #$i". $_POST['choice$i']; } or for($i=1;$i<=10;$i++) { echo "CHOICE #$i". $_POST['choice[$i]']; } i get nothing out... i'm really frustrated grr
  11. i just read somewhere that MySQL doesn't store boolean's? is this true?
  12. so i have a input form where a user gets to input 10 different things from a drop down menu. here is the page: www.the3guys.com/moto_game.php username:test password:4e138c I want to store all of the 10 inputs into an array so i can check to make sure each one is unique (so a person doesn't pick rider4 twice). now, i'm wondering if it would be better to store them straight into the MySQL database? Maybe have a bool that lets the script know if it is valid or not? anywho, i am basically searching for a nice way to validate the user input for the form above...
  13. OOOH, the user id/race id would stay the same in each entry, its just the racer_id that would change... GOOOT IT
  14. i'm having trouble visualizing how that would work using rhodesa's model for a database?
  15. that makes complete sense. So just to be clear you think the best way to store the picks would be in one column(racer_id: in USER_PICKS)? probably sepparated by a filler character like '/'? because each user will be picking 10 racers each week...
  16. ahhhh yes. now, would i store the 10 selections of each user in the 'racers' table? i think i was a little vague on that part. there are 40 actual racers that the users will be choosing from, they select what they think the top 10 racers of each race will be. this is compared to the actual results of the race, which would probably be another table.
  17. I'm not quite grasping your suggestion... are you saying to create a table for every user?
  18. I'll give you guys the background of the website I'm attempting to make: Essentially i am creating a game for a friend that is a motocross fanatic. I am creating a script that takes 10 riders from a user and compares it to the actual race data. The database structure needs to be set up to take 10 picks from probably quite a bit of users weekly (so space is an issue). This is the same for the race results database. I have the user table (name, password, email, etc.) set up already. I see this being able to go in a couple different directions, i'm just wondering what would be the easiest most efficient way to do this. First: Should i create the individual user's input table to house all of the picks in one slot? ex: User 1 | pick1/pick2/pick3 User 2 | Pick1/Pick2/Pick3 etc... or should i create it so each pick has its individual slot in the table? Second: Should i create an individual table for every race week or just append the table every week. I'm not positive how the second option could be done, but i'm assuming table's can be edited (i have too look into this obviously) Here is the general layout of the database i'm seeing User Database: Name User name password ID# etc... User input Database: ID# Picks Race#? (this is the part i'm unsure about) Race Results Database: Top 10 Over all Results So any suggestions are definitely encouraged and welcome
  19. how do i turn on full error reporting? and thanks PFM
  20. i do have the permissions set up correctly. here is my database connect string: <?php // db.php $dbhost = "localhost"; $dbuser = "thethrgu_derek"; $dbpass = "goodhabit"; function dbConnect($db="") { global $dbhost, $dbuser, $dbpass; $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass) or die("The site database appears to be down."); if ($db!="" and !@mysql_select_db($db)) die("The site database is unavailable."); return $dbcnx; } ?>
  21. So, i've been trying to fix this error for over an hour. i don't know why i am getting the error "Table 'thethrgu_moto.fans' doesn't exist" here is the code that is problematic, i'm guessing it has something to do with the table create. $query = 'CREATE TABLE fans( '. 'screenName VARCHAR(20) NOT NULL, '. 'email VARCHAR(50) NOT NULL, '. 'realName VARCHAR(30) NOT NULL, '. 'password VARCHAR (30) NOT NULL, '; $result = mysql_query($query); if(!result) { echo "database error:". mysql_error(); } $sql = "SELECT COUNT(*) FROM fans WHERE screenName = '$_POST[newid]'"; $result = mysql_query($sql); if (!$result) { echo "FUCKING ERROR: " . mysql_error(); } i'm just confused because it works with apache friends on my localhost, but when i took it live through blueHost i get this hang up very frustrated, if any one can tell me whats going on here it'd be great. here is the site www.the3guys.com/signup.php
  22. i just need to take the time to comment how awesome this site is... 'nuff said
  23. ok, i tried moving my script above the <html> tags and removing all of the output... but i still get the output error which is Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\motogame\Login.php:2) in C:\xampp\htdocs\motogame\Login.php on line 54 here is my entire login.php file: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <?php function sanityCheck($string, $type, $length){ // assign the type $type = 'is_'.$type; if(!$type($string)) { return FALSE; } // to check if there is anything in the string elseif(empty($string)) { return FALSE; } // to check how long the string is elseif(strlen($string) > $length) { return FALSE; } else { // if all is well, we return TRUE return TRUE; } } function checkSet(){ return isset($_POST['login'], $_POST['pword']); } if(checkSet() !=FALSE) { if(empty($_POST['login'])==FALSE && sanityCheck($_POST['login'], 'string', 25)!=FALSE && empty($_POST['pword'])==FALSE && sanityCheck($_POST['pword'], 'string', 25)!=FALSE) { $link = @mysql_connect('localhost', 'root', 'zOinks12'); if (!$link) { die('Not connected : ' . mysql_error()); } $db_selected = mysql_select_db('moto', $link); if (!$db_selected) { die ("Database not selected : " . mysql_error()); } $query = "SELECT realName, screenName, password, uID FROM fans"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { if($row[screenName]==$_POST['login']) { if($row[password]==$_POST['pword']) { header ("Location: moto_game.php"); exit(); } else { exit(); } } } } else { exit(); } } ?> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Login</title> </head> <body> <form action="Login.php" method="post"> screen name: <input type="text" name="login" maxlength="25"><br> password: <input type="password" name="pword" maxlength="25"><br> <input type="submit" name="submitbtn" value = "Login!"> </form> or Signup <a href="SignUp.php">here</a> <br> </body> </html>
  24. well how would i rebuild it to send headers?
×
×
  • 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.