Closed Thread Icon

Topic awaiting preservation: SQL syntax error...*sigh* (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12777" title="Pages that link to Topic awaiting preservation: SQL syntax error...*sigh* (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: SQL syntax error...*sigh* <span class="small">(Page 1 of 1)</span>\

 
fenja
Bipolar (III) Inmate

From: Norway
Insane since: Mar 2002

posted posted 06-08-2003 01:07

Hi!

I'm trying to learn PHP and MySQL. I've been stuck in a tutorial at Lycos and I have no idea what to do!
The tutorial is here : http://www.tripod.lycos.co.uk/webmaster/topics/technic/php/php-workshop5/1/

Even if I type everything exactly as it is in the tutorial, I still get this error when I open the site: SQL server reply: You have an error in your SQL syntax near '' at line 1.

I just can't find the mistake! I've done the whole tutorial many times but still get the same error!

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 06-08-2003 02:01

Hi fenja

We would need to see the code that your using to see what the problem may be. Link to it as a .txt file or post it here and I'm sure somebody will be able to help you out.

-Butcher-

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 06-08-2003 10:35

ok, my basic idea would be that you put the sql string in 'the other types of quotes', but kept those inside the way they were...
so if it was in " in the tutorial, you may have put it in '... or visa verca,
but it is really hard to tell, without actually seeing the query (or even better, the line of php you're doing the query in, so that we can also see the surrounding quotes).

One bit of note:
The die function of that script is really stupid, even for debugging... here's how I normally do it.

function tp_query($query)
{
$result = mysql_query($query);
if !($result)
{
print 'DB Error:'. mysql_error(). ' <br> Query: '. $query;
die ("Sorry, something went wrong with the database.");
}
return $result;
}


that way you never need to type that stupid 'or die' (or 'or my_db_error()') again,
and plus you could later on easily log queries that failed.

so long,
TP

fenja
Bipolar (III) Inmate

From: Norway
Insane since: Mar 2002

posted posted 06-08-2003 12:40

Thanks for the help! I got it to work.

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 06-08-2003 13:15

cool!
If you need more help, just holler.
My ICQ seems to be the primary php-help station around these parts anyway ;-)

« BackwardsOnwards »

Show Forum Drop Down Menu