Need Php Help Again

Discussion in 'Gaming' started by AndrewR., Sep 18, 2005.

  1. AndrewR.

    AndrewR. Well-Known Member

    Age:
    34
    Posts:
    1,831
    Likes Received:
    0
    Joined:
    Aug 6, 2005
    Location:
    Scottsdale, Arizona
    Here it is:

    Submit.PHP
    Code:
    <select name="select">
    <option name="1">Pistols</option>
    <option name="2">Gas Pistols</option>
    <option name="3">Spring Rifles</option>
    <option name="4">Electric Rifles</option>
    <option name="5">Gas Rifles</option>
    <option name="6">Shotguns</option>
    <option name="7">Accessories</option>
    </select>
    
    <?php include("dbconnect.php") ?>
    <?php
    
    if(isset($_POST['submit'])) {
    
    $link=$_POST['link'];
    
    $name=$_POST['name'];
    
    $model=$_POST['model'];
    
    $status=$_POST['status'];
    
    $type=$_POST['type'];
    
    $buy=$_POST['buy'];
    
    if(select=="1") {
    $sql = mysql_query("INSERT INTO `pistols` ( `link` , `name` , `model`, `status`, `type`, `buy` ) VALUES ('$link', '$name', '$model', '$status', '$type', '$buy');");
    }
    if(select=="2") {
    $sql = mysql_query("INSERT INTO `gaspistols` ( `link` , `name` , `model`, `status`, `type`, `buy` ) VALUES ('$link', '$name', '$model', '$status', '$type', '$buy');");
    }
    if(select=="3") {
    $sql = mysql_query("INSERT INTO `springrifles` ( `link` , `name` , `model`, `status`, `type`, `buy` ) VALUES ('$link', '$name', '$model', '$status', '$type', '$buy');");
    }
    if(select=="4") {
    $sql = mysql_query("INSERT INTO `electricrifles` ( `link` , `name` , `model`, `status`, `type`, `buy` ) VALUES ('$link', '$name', '$model', '$status', '$type', '$buy');");
    }
    if(select=="5") {
    $sql = mysql_query("INSERT INTO `gasrifles` ( `link` , `name` , `model`, `status`, `type`, `buy` ) VALUES ('$link', '$name', '$model', '$status', '$type', '$buy');");
    }
    if(select=="6") {
    $sql = mysql_query("INSERT INTO `shotguns` ( `link` , `name` , `model`, `status`, `type`, `buy` ) VALUES ('$link', '$name', '$model', '$status', '$type', '$buy');");
    }
    if(select=="7") {
    $sql = mysql_query("INSERT INTO `accessories` ( `link` , `name` , `model`, `status`, `type`, `buy` ) VALUES ('$link', '$name', '$model', '$status', '$type', '$buy');");
    }
    
    echo 'Thank you for your new submission!';
    
    
    }
    
    ?>
    <form method="post" action="submit.php">
    <table width="52%" height="459" border="0">
    
    <tr>
    <td height="29" valign="top">Link </td>
    <td valign="top"> <input type="text" name="link" size="25">
    </td>
    </tr>
    <tr>
    <td valign="top">Name </td>
    <td valign="top"> <input name="name" type="text" size="25"> </td>
    </tr>
    <tr>
    <td valign="top">Model </td>
    <td valign="top"> <input name="model" type="text" size="25"> </td>
    </tr>
    <tr>
    <td height="85" valign="top">Status 
    </td>
    <td valign="top"> <textarea name="status" size="25"></textarea>
    </td>
    </tr>
    <tr>
    <td height="85" valign="top">Type 
    </td>
    <td valign="top"> <textarea name="type" size="25"></textarea>
    </td>
    </tr>
    <tr>
    <td height="85" valign="top">Buy 
    </td>
    <td valign="top"> <textarea name="buy" size="25"></textarea>
    </td>
    </tr>
    <tr>
    <td height="25" valign="top"></td>
    <td valign="top"><input type="submit" name="submit" value="Submit New Model!"></td>
    
    </tr>
    </table></form>
    
    Display.PHP
    Code:
    <?php include("dbconnect.php") ?>
    <?php include("style.css") ?>
    
    <?php
    
    $limit = 100; //
    $query = "SELECT * FROM pistols ORDER BY id DESC LIMIT 0, $limit";
    $result = mysql_query($query) or die("Error: " . mysql_error());
    if(mysql_num_rows($result) == 0){
    echo("There are no models!");
    }
    $bgcolor = "transparent";
    
    echo("<table bgcolor='transparent' width='100%' cellpadding='2' cellspacing='0'>");
    while($query=mysql_fetch_array($result)){
    extract($query);
    echo("<table>
    	<tr>
      <td><img src=$link></img></td>
      </tr>
      <tr>
      <td>[b]$name[/b]</td>
      </tr>
      <tr>
      <td>[i]$model[/i]</td>
      </tr>
      <tr>
      <td>[u]$status[/u]</td>
      </tr>
      <tr>
      <td>[b]$type[/b]</td>
      </tr>
      <tr>
      <td>[url="$buy><img"]</img>[/url]</td>
    	</tr>
    </table>"); } echo("</table>");
    
    ?>

    Okay, now, when I use submit.php to submit the new model, I get the message I should when it works but then it says it doesn't submit it to the table so I can't query the table and display it with display.php.

    I need help ASAP.
     
  2. BrokenFaith

    BrokenFaith Well-Known Member

    Posts:
    2,380
    Likes Received:
    0
    Joined:
    Sep 1, 2005
    hmm.. seems complicated
     
  3. LemoNade

    LemoNade Well-Known Member

    Age:
    37
    Posts:
    500
    Likes Received:
    0
    Joined:
    Dec 21, 2004
    Location:
    Southampton, England
    Try this, should get rid of the errors :)

    Code:
    <select name="select">
    	<option name="1">Pistols</option>
    	<option name="2">Gas Pistols</option>
    	<option name="3">Spring Rifles</option>
    	<option name="4">Electric Rifles</option>
    	<option name="5">Gas Rifles</option>
    	<option name="6">Shotguns</option>
    	<option name="7">Accessories</option>
    </select>
    
    <?php include("dbconnect.php") ?>
    <?php
    
    if(isset($_POST['submit'])) {
    
    $link=$_POST['link'];
    
    $name=$_POST['name'];
    
    $model=$_POST['model'];
    
    $status=$_POST['status'];
    
    $type=$_POST['type'];
    
    $buy=$_POST['buy'];
    
    if(select=="1") {
    $sql = mysql_query("INSERT INTO `pistols` ( `link` , `name` , `model`, `status`, `type`, `buy` ) VALUES ('$link', '$name', '$model', '$status', '$type', '$buy');");
    }
    if(select=="2") {
    $sql = mysql_query("INSERT INTO `gaspistols` ( `link` , `name` , `model`, `status`, `type`, `buy` ) VALUES ('$link', '$name', '$model', '$status', '$type', '$buy');");
    }
    if(select=="3") {
    $sql = mysql_query("INSERT INTO `springrifles` ( `link` , `name` , `model`, `status`, `type`, `buy` ) VALUES ('$link', '$name', '$model', '$status', '$type', '$buy');");
    }
    if(select=="4") {
    $sql = mysql_query("INSERT INTO `electricrifles` ( `link` , `name` , `model`, `status`, `type`, `buy` ) VALUES ('$link', '$name', '$model', '$status', '$type', '$buy');");
    }
    if(select=="5") {
    $sql = mysql_query("INSERT INTO `gasrifles` ( `link` , `name` , `model`, `status`, `type`, `buy` ) VALUES ('$link', '$name', '$model', '$status', '$type', '$buy');");
    }
    if(select=="6") {
    $sql = mysql_query("INSERT INTO `shotguns` ( `link` , `name` , `model`, `status`, `type`, `buy` ) VALUES ('$link', '$name', '$model', '$status', '$type', '$buy');");
    }
    if(select=="7") {
    $sql = mysql_query("INSERT INTO `accessories` ( `link` , `name` , `model`, `status`, `type`, `buy` ) VALUES ('$link', '$name', '$model', '$status', '$type', '$buy');");
    }
    
    echo 'Thank you for your new submission!';
    
    
    }
    
    ?>
    <form method="post" action="submit.php">
    <table width="52%" height="459" border="0">
    
    <tr>
    <td height="29" valign="top">Link </td>
    <td valign="top"> <input type="text" name="link" size="25">
    </td>
    </tr>
    <tr>
    <td valign="top">Name </td>
    <td valign="top"> <input name="name" type="text" size="25"> </td>
    </tr>
    <tr>
    <td valign="top">Model </td>
    <td valign="top"> <input name="model" type="text" size="25"> </td>
    </tr>
    <tr>
    <td height="85" valign="top">Status 
    </td>
    <td valign="top"> <textarea name="status" size="25"></textarea>
    </td>
    </tr>
    <tr>
    <td height="85" valign="top">Type 
    </td>
    <td valign="top"> <textarea name="type" size="25"></textarea>
    </td>
    </tr>
    <tr>
    <td height="85" valign="top">Buy 
    </td>
    <td valign="top"> <textarea name="buy" size="25"></textarea>
    </td>
    </tr>
    <tr>
    <td height="25" valign="top"></td>
    <td valign="top"><input type="submit" name="submit" value="Submit New Model!"></td>
    
    </tr>
    </table></form>
     
  4. AndrewR.

    AndrewR. Well-Known Member

    Age:
    34
    Posts:
    1,831
    Likes Received:
    0
    Joined:
    Aug 6, 2005
    Location:
    Scottsdale, Arizona
    Thank you so much, testing it right now.
     
  5. AndrewR.

    AndrewR. Well-Known Member

    Age:
    34
    Posts:
    1,831
    Likes Received:
    0
    Joined:
    Aug 6, 2005
    Location:
    Scottsdale, Arizona
    It still doesn't work. It says that you submitted something but for some reason it doesn't submit it to the database.

    Oh, my tables were screwed up, nevermind.
     
  6. AndrewR.

    AndrewR. Well-Known Member

    Age:
    34
    Posts:
    1,831
    Likes Received:
    0
    Joined:
    Aug 6, 2005
    Location:
    Scottsdale, Arizona
    Bumping with edited post, need more help.
     
  7. BrokenFaith

    BrokenFaith Well-Known Member

    Posts:
    2,380
    Likes Received:
    0
    Joined:
    Sep 1, 2005
    Hmm, i donno whats wronng, it all looks okay, does anyone else know why it wont work still?
     
  8. LemoNade

    LemoNade Well-Known Member

    Age:
    37
    Posts:
    500
    Likes Received:
    0
    Joined:
    Dec 21, 2004
    Location:
    Southampton, England
    Add the following line to the top of the script:

    Code:
    error_reporting(E_ALL);
    Run it again and see what errors/warnings you get.
     

Share This Page