Forum Moderators: open

Message Too Old, No Replies

php sql syntax error from 'SHOW WARNINGS'.

         

steven420

7:14 pm on Apr 4, 2007 (gmt 0)

10+ Year Member



Hello I've been having problems with a script that uploads txt files to a database. When I run the script I get a bunch of warnings. The problem I'm having is that I need to see the warnings but when I use 'SHOW WARNINGS' I get a syntax error. I'm not sure why I get the syntax error. here is the code for the query:
 
$sql_4 = "SHOW WARNINGS;";
$query_4 = mysql_query($sql_4);
if(($query_4)=== FALSE)
{
die('warnings failed: ' . mysql_error());
}

This is realy killing me. Please help.

Thanks,
Steven.

jatar_k

7:17 pm on Apr 4, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what is the exact syntax error you are getting?

have you tried the exact same thing from the command line?

are you only getting the error on one specific query, or all the time?

steven420

7:27 pm on Apr 4, 2007 (gmt 0)

10+ Year Member



Whoops I can't believe I forgot this. 'You have an error in your SQL syntax near 'WARNINGS' at line 1'.

Ive tried this from phpmyadmin. And I only get this syntax error for this query. The query that uploads the data works sort of. It uploads 9443 lines of data then skips 100. and says there is 9543 warnings.

P.S Thanks for the speedy reply.

jatar_k

7:43 pm on Apr 4, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



"The query that uploads the data"

INSERT or LOAD DATA?

does anything end up in the db?

if you have command line access you could try that. I wonder if phpmyadmin is doing something funky that you can't see. Your syntax is actually right, though how you enter queries in phpmyadmin is not my forte

eelixduppy

7:52 pm on Apr 4, 2007 (gmt 0)



You also shouldn't include the semi-colon at the end of your query:

$sql_4 = "SHOW WARNINGS"; #it should look like this

steven420

10:05 pm on Apr 4, 2007 (gmt 0)

10+ Year Member



I am using 'LOAD DATA LOCAL INFILE' and some data is making it into the database but then there are some warnings and the rest of the data isn't being inserted. I only tried phpmyadmin. I am trying to do it with a script. I have tried it with and without the semicolon. I'm wondering if it isn't working because the 'SHOW WARNINGS' isn't part of the query that i'm having problems with. Unfortionatly you can only do one query at a time in php. Also i should mention that the query is done inside a loop. I did mysql_info() and it says 'Records: 9463 Deleted: 0 Skipped: 100 Warnings: 9595' for the first set of data and then Records: 9463 Deleted: 0 Skipped: 9463 Warnings: 9595' for the rest of the inserts.

Thanks,
Steven.

steven420

10:43 pm on Apr 4, 2007 (gmt 0)

10+ Year Member



Well I figured out what was wrong. 'SHOW WARNINGS' was implemented as of 4.1 and I have 3.23. Is there anothe way to see these errors in 3.23?