What's wrong?

Discussion in 'Databases' started by Thiagoo, Nov 25, 2006.

  1. #1
    I tried to do a script to upload content to my website, its really simple, i've already created DB and title/cons/text.

    send.php
    <?php
    $require("connectdb.php");
    $sqlinsert = "INSERT INTO 'Cheats' ( 'title' , 'cons' , 'text' )
    VALUES ('$title' , '$cons' , '$text')";
    mysql_query($sqlinsert) or die ("Error");
    echo "Cheat $title added";
    ?>

    add.php
    <form action="send.php" method="post" name="Cheats" id="Cheats"><table width="300"><tr><td>Game name:</td><td><input name="title" type="text" id="title" size="30"></td></tr></table>
    <p>
    <select name="cons" size="5" id="cons">
    <option value=1 id="Playstation">Playstation
    <option value=2 id="Playstation 2">Playstation 2

    </select>
    </p>
    <p>Cheat: <br>
    <textarea name="text" id="text"></textarea>
    </p>
    <p><input type="submit" name="submit" value="Send cheat"></p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    </form>

    connectdb.php
    <?php
    $hostname = 'localhost';
    $username = '12';
    $pass = '12';
    $data = 'Cheats';
    $db = mysql_connect($hostname, $username, $pass);
    mysql_select_db($data, $db);
    ?>
     
    Thiagoo, Nov 25, 2006 IP
  2. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you get any errors ? Is any data inserted ? Looks fine from here but if your php config has register_globals off then you'll need to add something like :
    
    $title=$_POST['title'];
    $cons=$_POST['cons'];
    $text=$_POST['text']; 
    
    PHP:
    at the beginning of send.php
     
    maiahost, Nov 25, 2006 IP
  3. thedark

    thedark Well-Known Member

    Messages:
    1,346
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    168
    Digital Goods:
    1
    #3
    or you should use extract($_POST);
     
    thedark, Nov 25, 2006 IP