SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Help with script

  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Location
    Scotland
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with script

    Hello,

    I am quite new to PHP but have managed quite well so far, my problem is with the script below. Can anyone help me?

    It generates this message:

    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 '()' at line 6
    From this code:


    PHP Code:
    <html>

    <form name="form1" method="post" action="<?=$_SERVER['PHP_SELF']?>">
      <p>Article Name: 
        <input name="heading" type="text" id="heading" size="50">
    </p>
      <p>Article Text: 
        <textarea name="article" cols="100" rows="15" id="article"></textarea>
    </p>
      <p>Author: 
        <input name="author" type="text" id="author"> 
        Source: 
        <input name="source" type="text" id="source">
    </p>
      <p>
        <input type="submit" name="submitnews" value="Submit">
    </p>
    </form>



    <?

    // Connecting
    $connect = @mysql_connect('localhost''root''martin');
    if (!
    $connect) {
    die( 
    '<p>problem ' mysql_error() . '</p>');
    }

    // Select Database
    $select = @mysql_select_db('mortgage');
    if (!
    $select) {
    die( 
    '<p>problem ' mysql_error() . '</p>');
    }    

    if (isset(
    $_POST ['submitnews'])) {
        
    $heading $_POST['heading'];
        
    $article $_POST['article'];
        
    $author $_POST['author'];
        
    $source $_POST['source'];

        
    $sql "INSERT INTO news SET
            heading = '
    $heading',
            article = '
    $article',
            author = '
    $author',
            source = '
    $source',
            articledate = CURRDATE()"
    ;
            
    if (@
    mysql_query($sql)) {
        echo(
    '<p>Your article has been submitted</p>');
        } else {
        echo(
    '<p>Houston We have a problem!' mysql_error() . '</p>');

        }
    }

    ?>
    </html>

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Location
    Scotland
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found it!

    CURRDATE() should be CURDATE()

Bookmarks

Posting Permissions

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