Parse Error, that i can't seem to find.
Posted: Wed Apr 21, 2004 4:07 pm
Hey,
i have been punding my head agains this parse error for about a day now, and have come no closer to solving the problem. I thought that i might post it here and see if anybody had any ideas. the error is:
Warning: pg_query(): Query failed: ERROR: syntax error at or near ";" at character 31 . in /home/nick/include/dbobj.php on line 157
so i go and look at line 157 heres a code snipet of the function that it is in:
anyways, line 157 is the line where i run the query (ie: pg_query). Can anybody see the problem?? Thanks in advance.
i have been punding my head agains this parse error for about a day now, and have come no closer to solving the problem. I thought that i might post it here and see if anybody had any ideas. the error is:
Warning: pg_query(): Query failed: ERROR: syntax error at or near ";" at character 31 . in /home/nick/include/dbobj.php on line 157
so i go and look at line 157 heres a code snipet of the function that it is in:
Code: Select all
function dbSelect($what, $from, $where)
{
/////////////////////////////////////////////////////////////////////////////////////
// Purpose: This function lets you do a select from the db that you just connected //
// too. //
// Pre: The connection has to be made, also you need to send at least the what //
// and from vars for this function to run. //
// Example: if you wanted to select all cats from the table called cats: //
// dbSelect("*", "cats", ""); //
// if you wanted to select all the cats from the table called cats //
// that are red: //
// dbSelect("*", "cats", "color=red"); //
// Post: Returns the record set. Returns false if it blew up. //
// Date Created: 04/21/04 //
// Date Finished: 04/21/04 //
/////////////////////////////////////////////////////////////////////////////////////
if ($where = "") //if where is equl to nothing, then built the sql without it.
{
$sql = "SELECT {$what} FROM {$from};";
}
else //else sql includes the where clause.
{
$sql = "SELECT {$what} FROM {$from} WHERE {$where};";
}
echo $sql;
$res = pg_query($sql);
if ($res <> false)
{
return $res;
}
else
{
return false;
}
}