PHP queries

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bogglebeats
Forum Newbie
Posts: 1
Joined: Wed Oct 30, 2002 12:20 pm

PHP queries

Post 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));
User avatar
cavey
Forum Newbie
Posts: 4
Joined: Wed Oct 30, 2002 12:50 pm

Post 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));
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply