Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resource ID error?

Status
Not open for further replies.

jisoo22

Programmer
Apr 30, 2001
277
US
Hello all,

I'm running PHP and postgresql and have run into a little problem with a select statement. By all accounts it should work beause I don't see any errors but perhaps someone else can point out something. Here's the code:

$get_disc_name = "SELECT t0.discipline_name FROM discipline t0 WHERE disc_id = $_POST[disc_id]";
$disc_name = pg_query($conn, $get_disc_name);

Thanks,
Jisoo22
 
There could be lots of things causing problems. Without error messages, I'll have to throw out multiple things.

The query would likely be better constructed as:
$get_disc_name = "SELECT t0.discipline_name FROM discipline t0 WHERE disc_id = " . $_POST['disc_id'];

PHP can get confused when you reference associative arrays inside strings.

It could be that your connection to PostgreSQL didn't work, so $conn does not contain a valid database connection handle.

It could be your query, though well-formed, is not valid for your database schema.




Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top