PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
lloydie-t
Forum Commoner
Posts: 88 Joined: Thu Jun 27, 2002 3:41 am
Location: UK
Post
by lloydie-t » Fri Nov 07, 2003 12:56 pm
I Have just had having an hour trying to make a script run and then by putting an extra line in it works OK. It is just a simple script to insert a record in to MySQL. Can anyone explain why this may be? Have a look at the codes:
working code
Code: Select all
$job_id = mysql_insert_id();
$sql="INSERT INTO actions (job_id, user_id, action_time, action_notes)
VALUES ('$job_id', '$user_id', '$today', '$action_notes')";
mysql_query($sql) or die('An error occured executing sql statement. SQL='.$sql.'<br>'.mysql_error());
non working code
Code: Select all
$job_id = mysql_insert_id();
$sql="INSERT INTO actions (job_id, user_id, action_time, action_notes)
VALUES ('$job_id', '$user_id', '$today', '$action_notes')";
mysql_query($sql) or die('An error occured executing sql statement. SQL='.$sql.'<br>'.mysql_error());
WaDaYaThink
m3mn0n
PHP Evangelist
Posts: 3548 Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada
Post
by m3mn0n » Fri Nov 07, 2003 6:21 pm
I've never heard of that happening before.
Very odd..
Jade
Forum Regular
Posts: 908 Joined: Sun Dec 29, 2002 5:40 pm
Location: VA
Post
by Jade » Fri Nov 07, 2003 9:48 pm
Are you sure you didn't just forget to put in a semicolon at the end of your $sql statement? I know its there now, but that looks to me like the most possible explination.
Jade
lloydie-t
Forum Commoner
Posts: 88 Joined: Thu Jun 27, 2002 3:41 am
Location: UK
Post
by lloydie-t » Sat Nov 08, 2003 2:09 am
Believe me, all I done was put the cursor on it and hit return to sort the problem
JAM
DevNet Resident
Posts: 2101 Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:
Post
by JAM » Sat Nov 08, 2003 6:07 am
And the error msg reads what?
lloydie-t
Forum Commoner
Posts: 88 Joined: Thu Jun 27, 2002 3:41 am
Location: UK
Post
by lloydie-t » Sat Nov 08, 2003 9:50 am
Exactly, no error message.
JAM
DevNet Resident
Posts: 2101 Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:
Post
by JAM » Mon Nov 10, 2003 5:28 am
Extremely annoying =)
Now I'm fishing...
What editor do you use?
If you place the enitre setting $sql on one single, long row, still get the same error?