PDA

View Full Version : What is wrong with this query?


NeverBored
07-04-2009, 10:54 PM
This query works and does exactly what I want, but it causes problems on my server with persistent connections, or something like that. When I take this out of my script my issues go away so I can only assume this is the problem. My host said something about having the query run then dropping the connection... I really don't know what that means or how to do it. My knowledge of this is pretty limited obviously, I wrote this query by looking through other files and piecing it together until I had something that did what I wanted.

global $db;
$ytvideo = $db->query_read("SELECT threadid FROM thread WHERE ytvideo = '$v'");

if($row = $db->fetch_array($ytvideo))
{
$ytvideoid = $row[threadid];
}

All I'm doing is finding the thread ID of the thread that has the matching column of $v in "ytvideo", if it exists, note that not all $v's have a matching thread - if that makes any difference...

Lynne
07-04-2009, 11:16 PM
First off, you shouldn't have quotes around the $v because that implies it's a string and I'm pretty sure it's a number?

Is the result going to be just one threadid? If so use query_read_first (I think that's it - doing it from memory) and then leave out the whole next four line (the if with the parenthesis) and just say
$ytvideoid = $ytvideo[threadid];

(No need for the whole fetch_array thing when using query_first)