Empty line allows script to run

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

Post Reply
lloydie-t
Forum Commoner
Posts: 88
Joined: Thu Jun 27, 2002 3:41 am
Location: UK

Empty line allows script to run

Post by lloydie-t »

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
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

I've never heard of that happening before. 8O Very odd..
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Post by Jade »

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 »

Believe me, all I done was put the cursor on it and hit return to sort the problem
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

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 »

Exactly, no error message.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

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?
Post Reply