Rows with mysql_unbuffered_query()?

I need help finding rows in a atable using mysql_unbuffered_query()…

$select2 = mysql_unbuffered_query("
SELECT id FROM `accounts`
WHERE `email` = '" . $email . "' || `name` = '" . $name . "'
quit('Someone already has your email address or character name!');

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /register.php on line 39
Someone already has your email address or character name!

SELECT id FROM accounts
WHERE email = ‘" . $email . "’ || name = ‘" . $name . "’
") or die(mysql_error());

I’m guessing it doesn’t like the ||, try using OR instead.

Still doesn’t work :frowning:

Then i’d put the query in a var and echo it to make sure it’s what you expect.
Like :
$sql = “SELECT id FROM accounts
WHERE email = ‘$email’ OR name = ‘$name’”;
echo $sql;
$select2 = mysql_unbuffered_query($sql) or die(mysql_error());

I removed the backquotes as that’s a phpMyAdmin’ism, also add an or die(mysql_error()) to the mysql_connect()

nothing good man :frowning:

DraginX, why an unbuffered query? i’ve never used that (in fact, i’ve never called mysql from php, but let’s not go into that), but the way i read the description of that function, its purpose is to allow you to start processing a large result set before mysql has finished producing it all

how large can your result set be? you have thousands of rows with the same email and name???

Unbuffered queries are more efficient. The way a standard query works, the script blocks until the mysql thread has read ALL the data from the query into memory. Then the script resumes.

With an unbuffered query the script continues while the mysql thread runs in the background. One can continue doing other tasks in the script while it builds, or get straight to work on the data as it comes in. The memory saving occurs where a result with 100,000 rows in standard query requires the memory of 100,000 records. But processing the same unbuffered query may only need 20,000 rows buffered at any time, and the script will complete in half the time because it can continue running while the data is received.

The problem is not emphasized but it is stated on the documentation. only 1 query can be run at a time.

//do mysql_connection
//grab needed data in background
$settings = mysql_unbuffered_query(“SELECT * FROM settings;”);

//load local configurations
$local_dir = dirname(file);

while($setting = mysql_fetch_assoc($settings)){


This script can load the database settings in the background while doing disk-access includes, but if any include run ANY kind of of query, $settings, while still being a mysql_resource_2, will be invalid result resource. An unbuffered query must be processed before any other mysql command is used or the [un]buffered data is discarded.

try it:
$result_1 = mysql_unbuffered_query();
/// some code
while($row = mysql_fetch_assoc($result_1))

$result_2 = mysql_unbuffered_query();
/// all works fine


$result_1 = mysql_unbuffered_query();
$result_2 = mysql_unbuffered_query();
while($row = mysql_fetch_assoc($result_1))

congrats, ppostma1, this thread is over eight years old

we can assume the original poster no longer cares, eh

Holy rising of the dead, batman! THREAD CLOSED