Page 1 of 1

PHP queries

Posted: Wed Oct 30, 2002 12:20 pm
by bogglebeats
I can't get the $result query to work. i keep getting a parse error. something to do with the quotes i think. can someone please help me?

$newartist = mysql_query("SELECT Distinct City, Genre_Select FROM Musicians_Network WHERE Date_Created > curdate()-7", $db);


if ($myfirstrow = mysql_fetch_array($newartist)) {

do {


$result = mysql_query("SELECT Contact FROM Musicians_Network WHERE (City = ". $myfirstrow['City'] ." or Genre_Select = ".
$myfirstrow['Genre_Select']) ." and Updates = 'Yes'",$db);

}while ($myrow = mysql_fetch_array($newartist));

Posted: Wed Oct 30, 2002 12:50 pm
by cavey
$newartist = mysql_query("SELECT Distinct City, Genre_Select FROM Musicians_Network WHERE Date_Created > curdate()-7", $db);


if ($myfirstrow = mysql_fetch_array($newartist)) { <-- this one isn't "ended"

do {


$result = mysql_query("SELECT Contact FROM Musicians_Network WHERE (City = ". $myfirstrow['City'] ." or Genre_Select = ".
$myfirstrow['Genre_Select']) ." and Updates = 'Yes'",$db);

}while ($myrow = mysql_fetch_array($newartist));

Posted: Thu Oct 31, 2002 2:30 am
by twigletmac
First of all, please do not cross-post, as mydimension pointed out in your other post (which has now been deleted) it is confusing for everyone.

Cavey's right, you're missing a closing bracket for your if statement. To make your code easier to read and to debug though, you should try moving your SQL queries into their own variables so you can echo them out to check they're alright. Instead of a do...while loop just use a while one:

Code: Select all

while ($row = mysql_fetch_assoc($result)) {
   // do stuff
}
Also consider whether you need multiple queries to pull information from the same table.

Mac