|
Posted by Erwin Moller on 02/03/06 17:40
JT wrote:
> I am working on a basic webpage in PHP connecting to a mySQL database,
> here is my query...
>
> //query 1
> $query_rs_staff = "SELECT * FROM jtStaff WHERE
> locationID=".$_GET['myDesk'];
> $rs_staff = mysql_query($query_rs_staff);
> $row_rs_staff = mysql_fetch_assoc($rs_staff);
>
Looks fine.
>
> //query 2
> $query_rs_section = "SELECT * FROM jtSection WHERE
> sectionID=$row_rs_staff['sectionID']";
Looks NOT fine.
Debugging is really easy with SQL.
Just place an echo here, like:
echo $query_rs_section;
exit;
and see what you make of it.
I am sure you'll fix it right away.
:-)
> $rs_section = mysql_query($query_rs_section);
> $row_rs_ssection = mysql_fetch_assoc($rs_section);
> ?>
>
>
> I had it working with query 1. then I added query 2 to get from another
>
> table, some additional data. So i have no problems with query 1. When
> ran thru my server, it throws back a parse error on line 20, which is
> the first line of query 2. can someone tell me the correct syntax for
> what i am trying to do here?
In general: When hitting on SQL-(syntax)problems:
1) Echo the SQL before you execute it, and exit right there.
You have the query now on your webpage.
2) Look at it. If you do not see a problem, copy it and feed it directly to
the database via terminal, or whatever way you use to talk to your database
directly.
Good luck,
Erwin Moller
>
>
> thanks
Navigation:
[Reply to this message]
|