Jump to content

chilllax

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Everything posted by chilllax

  1. I am trying to learn php (if you have any tips for better learning please post) and I created a form to submit info into the database and that worked. Now I want to display the contents of the database using this script: [code]<html> <title>Success, what a word.</title> <head> <h2>The contents of the database are as follows</h2> </head> <body> <?php $con = mysql_connect("localhost","chilllax_chillla","mypassword"); if (!$con)     {     die('Could not connect: ' . mysql_error());     } mysql_select_db("chilllax_tournament", $con); $sql = 'SELECT * FROM `survey` LIMIT 0, 30 '; ?> </body> </html>[/code] The problem is that only the header appears and nothing else. any help is greatly appriciated. [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
  2. Here is the code after the changes you told me to make. Unfortunatly it still isnt submitting the information into the database. Could there be something wrong with the settings of my columns that wouldnt allow information to be placed in it? If you need to know anything else just ask. [code]<html> <head> <title>Your Entry</title> </head> <table align="center"> <tr>   <td> <a href="http://www.officalhalo.com">Home</a> | <a href="/tournament/FFA.htm">FFA</a> | <a href="/tournament/signup.htm">Sign Up</a> | <a href="/tournament/results.htm">Results</a> | <a href="/tournament/participants.php">Participants</a> </td> </tr> </table> <body> <h3 align="center">Your Entry</h3> <?php   // Add to make sure you see PHP errors/warnings/notices ini_set('display_errors', '1'); error_reporting(E_ALL);      $gamertag=$_POST['gamertag'];   $eaddress=$_POST['eaddress'];      if (!$gamertag || !$eaddress)   {       echo 'You have not entered all of the required information.<br />'            .'Please go back and try again.';       exit;   }   @ $db = new mysqli('localhost', 'chilllax_chillla', 'red123', 'chilllax_tournament');    if (mysqli_connect_errno()) {     echo 'Error: Could not connect to database. Please try again later.';     exit; } $query = "INSERT INTO ffa (gamertag, eaddress) VALUES ('$gamertag', '$eaddress')"; $result = $db->query($query); if ($result)     echo $db->affected_rows.' Entry submitted into database.'; else {     echo 'Could not insert. Error: ', mysqli_error();     exit;  // } ?> </body> </html> [/code]
  3. I added the error in, that was a smart thing to do I didnt think of that thank you. Unfortunatly there is still no error only blank page when I run the script. So I am guessing my error lies in the bit of code that you told me to replace with this [code]define ('chilllax_tournament', 'MyTableNamePrefix_'); . . . $query = 'INSERT INTO ' . chilllax_tournament . "ffa (gamertag, eaddress) VALUES ('$gamertag', '$eaddress')"; [/code] Just to be sure, my table name is ffa and chilllax_tournament is the name of my databse. I copied your code verbatum but I dont think the periods seperating the first line with the second should be there correct? I tried to run the script with them and Parse error: parse error, unexpected '.' in /home/chilllax/public_html/tournament/yourentry.php on line 42 that error came up. Withouth the periods there was only a blank page. Thanks for all of your help.
  4. What I want to do is collect a gamers username and their email address send that into my database and then display all of the gamers who have signed up on another page using the database. I made the html form that was fairly simple. My problem is getting that information into the database. When I run the scrip that is supposed to put the information into the databse there is never an error but the information never gets put into the databse. Heres the code of the script (thanks for any help): [code] <html> <head> <title>Your Entry</title> </head> <table align="center"> <tr>   <td> <a href="http://www.officalhalo.com">Home</a> | <a href="/tournament/FFA.htm">FFA</a> | <a href="/tournament/signup.htm">Sign Up</a> | <a href="/tournament/results.htm">Results</a> </td> </tr> </table> <body> <h3 align="center">Your Entry</h3> <?php   $gamertag=$_POST['gamertag'];   $eaddress=$_POST['eaddress'];      if (!$gamertag || !$eaddress)   {       echo 'You have not entered all of the required information.<br />'            .'Please go back and try again.';       exit;   }   @ $db = new mysqli('localhost', 'chilllax_chillla', 'red123', 'chilllax_tournament');    if (mysqli_connect_errno()) {     echo 'Error: Could not connect to database. Please try again later.';     exit; } $query = "INSERT INTO " . chilllax_tournament ." ffa (gamertag, eaddress)               VALUES ("' $gamertag . '", "' . $eaddress . '")"; $result = $db->query($query); if ($result)     echo $db->affected_rows.' Entry submitted into database.';          $db->close(); ?> </body> </html> [/code]
×
×
  • 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.