For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > November 2004 > Select/query problem [newbie]









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Select/query problem [newbie]
Gwen Morse

2004-11-15, 8:55 am

// check first to see if the entry is _in_ the database
// Get record (SELECT).

$query ="SELECT * FROM testschedule WHERE (personid='$personid') AND
(day='$HTTP_POST_VARS[day]') AND (startt='$HTTP_POST_VARS[startt]')
AND (endt='$HTTP_POST_VARS[endt]')";
$result = mysql_query($query);
or die ("Couldn't execute query." . mysql_errno() .
mysql_error());

I'm getting a parse error ([error] PHP Parse error: parse error in
/externalweb/RCF/cgi-bin/MonitorScripts/calSub.php on line 159).

Line 159 is the 'or die' portion.

I've noticed parse errors point to a line or two after the real
problem. My best guess is that the query is actually "wrong" in some
way. Maybe I can't use three AND conditionals in the same select?

Gwen

Floortje

2004-11-15, 8:55 am

> $result = mysql_query($query);
> or die ("Couldn't execute query." . mysql_errno() .
> mysql_error());


compare

$query = mysql_query("$sql")
or exit ("Ongeldige query " . mysql_error());

Floortje


Andy Hassall

2004-11-15, 8:55 pm

On Mon, 15 Nov 2004 03:24:32 -0500, Gwen Morse <goldmooneachna@yahoo.com>
wrote:

>$result = mysql_query($query);

^^^

> or die ("Couldn't execute query." . mysql_errno() .
>mysql_error());


This is supposed to be a single statement; but you've terminated it after the
mysql_query(). Remove the first semicolon.

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Gwen Morse

2004-11-15, 8:55 pm

On Mon, 15 Nov 2004 21:28:03 +0000, Andy Hassall <andy@andyh.co.uk>
wrote:

> This is supposed to be a single statement; but you've terminated it after the
>mysql_query(). Remove the first semicolon.


Putting semi-colons in the wrong places (and leaving them off where
they're needed) is still the most common mistake I make. You'd think
I'd check things more carefully!

That said, is there an IDE that helps improve debugging? Right now, I
only get error messages from grep-ing the web server logs. It's an
awkward way to track down syntax errors/typos.

In my two programming classes at school (Java and Visual Basic), both
languages had a GUI-based IDE which caught syntax errors on the fly.
They also had debuggers that allowed me to step through the processing
of the code to see where I made logical errors. I tried a couple IDEs
mentioned at php.net, and the ones I d/led were simply glorified text
editors. I get syntax highlighting with Kate. I'm not sure if I picked
the wrong packages, or, if what I'm looking for is only available in
commercial apps.

I'm a linux user (FC2), if that matters.

Gwen

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com