Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-12-2005, 11:37 AM Problems with script
Novice Talker

Posts: 5
Trades: 0
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>

Last edited by wise1; 03-12-2005 at 11:50 AM..
wise1 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-12-2005, 12:45 PM
Buddha443556's Avatar
Novice Talker

Posts: 10
Trades: 0
Quote:
From the manual:

The INSERT ... SET syntax is supported in MySQL 3.22.10 or later.
Check the version of MySQL supports the INSERT ... SET syntax.

PS

CURRDATE()? Did you mean CURRENT_DATE, CURRENT_DATE() or CURDATE()?

Last edited by Buddha443556; 03-12-2005 at 12:55 PM.. Reason: Found error I think.
Buddha443556 is offline
Reply With Quote
View Public Profile
 
Old 03-12-2005, 02:00 PM
Novice Talker

Posts: 5
Trades: 0
Thank You!

It was CURRDATE () causing the problem, as you rightly pointed out it should have been CURDATE()

Thanks

Lee
wise1 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Problems with script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11857 seconds with 12 queries