Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Oct 2004
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    wots wrong here?

    itll run just not send it to the databse


    PHP Code:
    <html>

    <head>
    <title>New Page 1</title>
    <?
    // connect to dudey database!
    mysql_connect 'localhost''***_*******''*******' );
    mysql_select_db 'paper1_project' );
    // find thingy
    if ($_POST['name']) {
    $name $_POST['name'];
    $email $_POST['email'];
    $message $_POST['message'];

    mysql_query "INSERT INTO shoutbox ( '', '$name', '$email', '$message')" );
    }
    else
    {
    mysql_close();
    }
    ?>
    </head>

    <body bgcolor="#000000">

    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="165" id="AutoNumber1" height="272">
      <tr>
        <td height="219" width="165" valign="top">
        <?
        mysql_connect 
    'localhost''*_**''*******' );
        
    mysql_select_db 'paper1_project' );
        
    $shouts_result mysql_query "SELECT 'name', 'email', message FROM 'shoutbox' ORDER BY 'id' DESC LIMIT 5" );

    while ( 
    $row = @mysql_fetch_array $shouts_result ) ) {

    extract $row );

    echo 
    "<font color='#FFFFFF'><a href='mailto:$email'>$name</a><br/>$message</font><br/>";

    }
    mysql_close();
        
    ?>
    </td>
      </tr>
      <tr>
        <td height="53" width="165">
        <fieldset>

        <form action="<?$PHP_SELF?>" method="post">
           <p align="center" style="margin-top: 0; margin-bottom: 0"><font color="#FFFFFF"><b><font face="Verdana">Name: <input type="text" name="name" size="20"></font></b></font></p>
                 
           <p align="center" style="margin-top: 0; margin-bottom: 0"><b><font color="#FFFFFF" face="Verdana">Email:</font></b><font face="Verdana"><b><input type="text" name="email" size="20"></b></font></p>
                 
           <p align="center" style="margin-top: 0; margin-bottom: 0"><font color="#FFFFFF"><b><font face="Verdana">
           Message:</font></b></font><font face="Verdana"><b> <input type="text" name="message" size="20"></b></font><b><font face="Verdana"> </font>
           </b></p>
                 
           <p align="center" style="margin-top: 0; margin-bottom: 0"><font face="Verdana"><b>
    <input type="submit" value="Post"> </b></font></p>
                 
        </form>
        </fieldset>
        </td>
      </tr>
    </table>

    </body>

    </html>
    goto the site here
    Suppose so. but, oh forget it u win!

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Code:
    mysql_query ( "INSERT INTO shoutbox values ( '', '$name', '$email', '$message')" );
    You can use: or die(mysql_error()) also to help you debug...

  • #3
    New Coder
    Join Date
    Oct 2004
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    where wud i put the

    or die(mysql_error())
    Suppose so. but, oh forget it u win!

  • #4
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    After your mysql_query:
    PHP Code:
    mysql_query "INSERT INTO shoutbox values ( '', '$name', '$email', '$message')" ) or die(mysql_error()); 

  • #5
    New Coder
    Join Date
    Oct 2004
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    still a no go, current code is

    PHP Code:
    <html>

    <head>
    <title>New Page 1</title>
    <?
    // connect to dudey database!
    mysql_connect 'localhost''******_*******''******' );
    mysql_select_db '******_project' );
    // find thingy
    if ($_POST['name']) {
    $name $_POST['name'];
    $email $_POST['email'];
    $message $_POST['message'];

    mysql_query "INSERT INTO shoutbox values ( '', '$name', '$email', '$message')" ) or die(mysql_error());
    }
    else
    {
    mysql_close();
    }
    ?>
    </head>

    <body bgcolor="#000000">

    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="165" id="AutoNumber1" height="272">
      <tr>
        <td height="219" width="165" valign="top">
        <?
        mysql_connect 
    'localhost''******_*******''******' );
        
    mysql_select_db '******_project' );
        
    $shouts_result mysql_query "SELECT 'name', 'email', message FROM 'shoutbox' ORDER BY 'id' DESC LIMIT 5" );

    while ( 
    $row = @mysql_fetch_array $shouts_result ) ) {

    extract $row );

    echo 
    "<font color='#FFFFFF'><a href='mailto:$email'>$name</a><br/>$message</font><br/>";

    }
    mysql_close();
        
    ?>
    </td>
      </tr>
      <tr>
        <td height="53" width="165">
        <fieldset>

        <form action="<?$PHP_SELF?>" method="post">
           <p align="center" style="margin-top: 0; margin-bottom: 0"><font color="#FFFFFF"><b><font face="Verdana">Name: <input type="text" name="name" size="20"></font></b></font></p>
                 
           <p align="center" style="margin-top: 0; margin-bottom: 0"><b><font color="#FFFFFF" face="Verdana">Email:</font></b><font face="Verdana"><b><input type="text" name="email" size="20"></b></font></p>
                 
           <p align="center" style="margin-top: 0; margin-bottom: 0"><font color="#FFFFFF"><b><font face="Verdana">
           Message:</font></b></font><font face="Verdana"><b> <input type="text" name="message" size="20"></b></font><b><font face="Verdana"> </font>
           </b></p>
                 
           <p align="center" style="margin-top: 0; margin-bottom: 0"><font face="Verdana"><b>
    <input type="submit" value="Post"> </b></font></p>
                 
        </form>
        </fieldset>
        </td>
      </tr>
    </table>

    </body>

    </html>
    its a twat when no one knows

    it may be this :

    PHP Code:
    mysql_connect 'localhost''database username?''database password?' );
    mysql_select_db 'database?' ); 
    Last edited by matthew_haworth; 07-12-2005 at 06:28 PM.
    Suppose so. but, oh forget it u win!

  • #6
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Again, use mysql error to check if you actually make a connection to the database, use the example off of php.net:
    http://us2.php.net/mysql_connect

  • #7
    New Coder
    Join Date
    Oct 2004
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    tis is going to the database now, just not coming out

    FROM 'shoutbox' ORDER BY 'id' DESC LIMIT 5

    it says its near there

    Code:
    You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''shoutbox' ORDER BY 'id' DESC LIMIT 5' at line 1
    Last edited by matthew_haworth; 07-12-2005 at 07:05 PM.
    Suppose so. but, oh forget it u win!

  • #8
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    You're using single quotes around your field names?? Did you mean to use backticks? '`'? Anyrate, take out the single quotes and give it a go:
    PHP Code:
    $shouts_result mysql_query "SELECT name, email, message FROM shoutbox ORDER BY id DESC LIMIT 5" ); 

  • #9
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    You need to read our posting guidelines before creating any more threads.

    http://www.codingforums.com/postguide.htm

    Pay special attention to number 2
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •