Jump to content

mysql_fetch_array(): supplied argument is not a valid MySQL result ??


JTapp

Recommended Posts

This is driving me crazy.. I don' t know what I have done.... Can somebody look at my code?  The line that seems to be the problem is highlighted in red..

 

$id = $_GET['id'];

 

$query = mysql_query("SELECT a.strLodgeName, a.intLodgeNumber, a.strDistrictName, a.strLodgeWEB, a.strLodgeCounty, a.dtChartered, a.strLodgeMailingAddress, a.strLodgeMailingAddress2, a.strLodgeMailingCity, a.strLodgeMailingPostCode, a.strLodgeEmail, a.strLodgePhone, a.strLodgeFax, a.strDrivingDirectons, a.dtMeetingTime, a.dtMealTime, a.strFloorSchool, a.strLodgeNews, b.strOfficerTitle, b.strFirstName, b.strLastName, b.BusinessPhone, b.PersEmail FROM tblLodges a LEFT JOIN tblOfficers b ON a.lngLodgeID = b.lngLodgeID WHERE a.intLodgeNumber=$id GROUP BY a.strLodgeName LIMIT 50");

while ($row = @mysql_fetch_array($query))

 

{

$variable1=$row["strLodgeName"];

$variable2=$row["intLodgeNumber"];

$variable3=$row["strDistrictName"];

$variable4=$row["strLodgeWEB"];

$variable5=$row["strLodgeCounty"];

$variable6=$row["dtChartered"];

$variable7=$row["strLodgeMailingAddress"];

$variable8=$row["strLodgeMailingAddress2"];

$variable9=$row["strLodgeMailingCity"];

$variable10=$row["strLodgeMailingStateCode"];

$variable11=$row["strLodgeMailingPostCode"];

$variable12=$row["strLodgeEmail"];

$variable13=$row["strLodgePhone"];

$variable14=$row["strLodgeFax"];

$variable15=$row["strDrivingDirectons"];

$variable16=$row["dtMeetingTime"];

$variable17=$row["dtMealTime"];

$variable18=$row["strFloorSchool"];

$variable19=$row["strLodgeNews"];

$variable20=$row["link"];

//table layout for results

 

echo ("<tr>");

echo "<center>\n";

echo "<p>GRAND LODGE OF LOUISIANA - LODGE LOCATOR RESULTS\n</p>";

echo "Lodge Name: $variable1</p>";

echo "<p><b>Lodge Number:</b> $variable2</p>";

echo "<p><b>District Name:</b> $variable3</p>";

echo "<a href=\"$variable4\">Click Here To Go To The Lodge Website</a>";

echo "<p><b>Lodge County:</b> $variable5</p>";

echo "<p><b>Lodge Chartered On:</b> $variable6</p>";

echo "<p><b>Lodge Address:</b> $variable7, $variable8</p>";

echo '<p>' . $variable9 . $variable10 . $variable11 . '</p>';

echo "Click Here To Email The Lodge";

echo "<p>Lodge Phone Number: $variable13, Lodge FAX Number: $variable14</p>";

echo "<p>Lodge Driving Directions: $variable15</p>";

echo "<p>Lodge Lodge Meeting Time: $variable16</p>";

echo "<p>Lodge Lodge Meal Time: $variable17</p>";

echo "<p>Lodge Floor School: $variable18</p>";

echo "<p>Lodge News: $variable19</p>";

echo "<img src='{$row['link']}'>";

echo "</center>\n";

echo ("</tr>");

}

?> </tr>

</table>

<hr width=75% align=center size=4>

 

 

<?php

 

//query details table begins

$query = mysql_query("SELECT tblLodges.strLodgeName, tblLodges.intLodgeNumber, tblLodges.strDistrictName, tblLodges.strLodgeMailingCity, tblLodges.strLodgeMailingPostCode, tblLodges.strLodgeCounty, tblOfficers.strOfficerTitle, tblOfficers.strFirstName, tblOfficers.strLastName, tblOfficers.BusinessPhone, tblOfficers.PersEmail FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' LIMIT 0, 50");

 

$results=mysql_query($query);

echo "<center>\n";

echo "<H2>Roster of Lodge Officers</H2>\n";

echo "<table border='1'>

<tr>

<th>Officer Title</th>

<th>Officer First</th>

<th>Officer Last</th>

<th>Officer Email</th>

<th>Officer Phone</th>

 

</tr>";

//

while ($row = mysql_fetch_array($query))

{

$variable1=$row["strOfficerTitle"];

$variable2=$row["strFirstName"];

$variable3=$row["strLastName"];

$variable4=$row["PersEmail"];

$variable5=$row["BusinessPhone"];

 

//table layout for results

 

print ("<tr>");

echo "<tr align=\"center\" bgcolor=\"#EFEFEF\">\n";

echo "<td class=\"td_id\">$variable1</td>\n";

echo "<td class=\"td_id\">$variable2</td>\n";

echo "<td class=\"td_id\">$variable3</td>\n";

echo "<td class=\"td_id\">$variable4</td>\n";

echo "<td class=\"td_id\">$variable5</td>\n";

print ("</tr>");

}

?>

 

theres probably somthing wroung in your query

 

use this

 

$query = mysql_query("SELECT tblLodges.strLodgeName, tblLodges.intLodgeNumber, tblLodges.strDistrictName, tblLodges.strLodgeMailingCity, tblLodges.strLodgeMailingPostCode, tblLodges.strLodgeCounty, tblOfficers.strOfficerTitle, tblOfficers.strFirstName, tblOfficers.strLastName, tblOfficers.BusinessPhone, tblOfficers.PersEmail FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' LIMIT 0, 50") or die (mysql_error());

 

it should point you the error

 

and for the

 

while ($row = mysql_fetch_array($query))

{

 

you should use

 

if (mysql_num_rows($query)) {

while ($row = mysql_fetch_array($query)){

$variable1=$row["strOfficerTitle"];

$variable2=$row["strFirstName"];

$variable3=$row["strLastName"];

$variable4=$row["PersEmail"];

$variable5=$row["BusinessPhone"];

 

//table layout for results

 

print ("<tr>");

echo "<tr align=\"center\" bgcolor=\"#EFEFEF\">\n";

echo "<td class=\"td_id\">$variable1</td>\n";

echo "<td class=\"td_id\">$variable2</td>\n";

echo "<td class=\"td_id\">$variable3</td>\n";

echo "<td class=\"td_id\">$variable4</td>\n";

echo "<td class=\"td_id\">$variable5</td>\n";

print ("</tr>");

}

}

 

Thanks.. I tried it and the new error message is the very last line of my code which is simply

 

?>

</body>

</html>

 

 

 

It says:

 

Parse error: syntax error, unexpected $end in /mnt/w0202/d07/s47/b021cdb1/www/3view.php on line 115

 

Any ideas?

Here  you are.. hopefully it's not that crazy for you to look at...

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

 

<body>

<?php

$username = "********";

$password = "********";

$hostname = "MYSQLHOST";

 

$dbhandle = mysql_connect($hostname, $username, $password)

  or die("Unable to connect to MySQL");

 

$selected = mysql_select_db("*********",$dbhandle)

  or die("Could not select *********");

 

 

$id = $_GET['id'];

 

$query = mysql_query("SELECT a.strLodgeName, a.intLodgeNumber, a.strDistrictName, a.strLodgeWEB, a.strLodgeCounty, a.dtChartered, a.strLodgeMailingAddress, a.strLodgeMailingAddress2, a.strLodgeMailingCity, a.strLodgeMailingPostCode, a.strLodgeEmail, a.strLodgePhone, a.strLodgeFax, a.strDrivingDirectons, a.dtMeetingTime, a.dtMealTime, a.strFloorSchool, a.strLodgeNews, b.strOfficerTitle, b.strFirstName, b.strLastName, b.BusinessPhone, b.PersEmail FROM tblLodges a LEFT JOIN tblOfficers b ON a.lngLodgeID = b.lngLodgeID WHERE a.intLodgeNumber=$id GROUP BY a.strLodgeName LIMIT 50");

while ($row = @mysql_fetch_array($query))

 

{

$variable1=$row["strLodgeName"];

$variable2=$row["intLodgeNumber"];

$variable3=$row["strDistrictName"];

$variable4=$row["strLodgeWEB"];

$variable5=$row["strLodgeCounty"];

$variable6=$row["dtChartered"];

$variable7=$row["strLodgeMailingAddress"];

$variable8=$row["strLodgeMailingAddress2"];

$variable9=$row["strLodgeMailingCity"];

$variable10=$row["strLodgeMailingStateCode"];

$variable11=$row["strLodgeMailingPostCode"];

$variable12=$row["strLodgeEmail"];

$variable13=$row["strLodgePhone"];

$variable14=$row["strLodgeFax"];

$variable15=$row["strDrivingDirectons"];

$variable16=$row["dtMeetingTime"];

$variable17=$row["dtMealTime"];

$variable18=$row["strFloorSchool"];

$variable19=$row["strLodgeNews"];

$variable20=$row["link"];

//table layout for results

 

echo ("<tr>");

echo "<center>\n";

echo "<p>GRAND LODGE OF LOUISIANA - LODGE LOCATOR RESULTS\n</p>";

echo "Lodge Name: $variable1</p>";

echo "<p><b>Lodge Number:</b> $variable2</p>";

echo "<p><b>District Name:</b> $variable3</p>";

echo "<a href=\"$variable4\">Click Here To Go To The Lodge Website</a>";

echo "<p><b>Lodge County:</b> $variable5</p>";

echo "<p><b>Lodge Chartered On:</b> $variable6</p>";

echo "<p><b>Lodge Address:</b> $variable7, $variable8</p>";

echo '<p>' . $variable9 . $variable10 . $variable11 . '</p>';

echo "Click Here To Email The Lodge";

echo "<p>Lodge Phone Number: $variable13, Lodge FAX Number: $variable14</p>";

echo "<p>Lodge Driving Directions: $variable15</p>";

echo "<p>Lodge Lodge Meeting Time: $variable16</p>";

echo "<p>Lodge Lodge Meal Time: $variable17</p>";

echo "<p>Lodge Floor School: $variable18</p>";

echo "<p>Lodge News: $variable19</p>";

echo "<img src='{$row['link']}'>";

echo "</center>\n";

echo ("</tr>");

}

?>

</tr>

</table>

<hr width=75% align=center size=4>

 

 

<?php

//query details table begins

$query = mysql_query("SELECT tblLodges.strLodgeName, tblLodges.intLodgeNumber, tblLodges.strDistrictName, tblLodges.strLodgeMailingCity, tblLodges.strLodgeMailingPostCode, tblLodges.strLodgeCounty, tblOfficers.strOfficerTitle, tblOfficers.strFirstName, tblOfficers.strLastName, tblOfficers.BusinessPhone, tblOfficers.PersEmail FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' LIMIT 0, 50")or die (mysql_error());

 

$results=mysql_query($query);

echo "<center>\n";

echo "<H2>Roster of Lodge Officers</H2>\n";

echo "<table border='1'>

  <tr>

<th>Officer Title</th>

<th>Officer First</th>

<th>Officer Last</th>

<th>Officer Email</th>

<th>Officer Phone</th>

 

</tr>";

//

 

if (mysql_num_rows($query)) {

while ($row = mysql_fetch_array($query)){

$variable1=$row["strOfficerTitle"];

$variable2=$row["strFirstName"];

$variable3=$row["strLastName"];

$variable4=$row["PersEmail"];

$variable5=$row["BusinessPhone"];

 

//table layout for results

 

print ("<tr>");

echo "<tr align=\"center\" bgcolor=\"#EFEFEF\">\n";

echo "<td class=\"td_id\">$variable1</td>\n";

echo "<td class=\"td_id\">$variable2</td>\n";

echo "<td class=\"td_id\">$variable3</td>\n";

echo "<td class=\"td_id\">$variable4</td>\n";

echo "<td class=\"td_id\">$variable5</td>\n";

print ("</tr>");

}

?>

</body>

</html>

<?php

 

Run just this, and tell me what you get:

<?php
$username = "********";
$password = "********";
$hostname = "MYSQLHOST";

$dbhandle = mysql_connect($hostname, $username, $password)
  or die("Unable to connect to MySQL");

$selected = mysql_select_db("*********",$dbhandle)
  or die("Could not select *********");

$id = $_GET['id'];

$query = mysql_query("SELECT tblLodges.strLodgeName, tblLodges.intLodgeNumber, tblLodges.strDistrictName, tblLodges.strLodgeMailingCity, tblLodges.strLodgeMailingPostCode, tblLodges.strLodgeCounty, tblOfficers.strOfficerTitle, tblOfficers.strFirstName, tblOfficers.strLastName, tblOfficers.BusinessPhone, tblOfficers.PersEmail FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' LIMIT 0, 50") or die(mysql_error());
?>

 

Also, you also use a variable $metode in both queries which is not defined (at least, not in the part of the script that you showed us)

You never close this if statement

if (mysql_num_rows($query)) {

 

So change the bottom of your code to this

<?php

if (mysql_num_rows($query)) {
    while ($row = mysql_fetch_array($query)) {
        $variable1=$row["strOfficerTitle"];
        $variable2=$row["strFirstName"];
        $variable3=$row["strLastName"];
        $variable4=$row["PersEmail"];
        $variable5=$row["BusinessPhone"];
        
        //table layout for results
        
        print("<tr>");
        echo "<tr align=\"center\" bgcolor=\"#EFEFEF\">\n";
        echo "<td class=\"td_id\">$variable1</td>\n";
        echo "<td class=\"td_id\">$variable2</td>\n";
        echo "<td class=\"td_id\">$variable3</td>\n";
        echo "<td class=\"td_id\">$variable4</td>\n";
        echo "<td class=\"td_id\">$variable5</td>\n";
        print("</tr>");
    }
}
?>

 

Also, why is your very last line of code opening PHP tags? Unless that wasn't your entire script?

 

Also, I don't really see the point of this line:

$results=mysql_query($query);

pocobueno1388 -

 

Yes, that was all of the code.. You just caught me when I was reading http://www.phpbuilder.com/board/showthread.php?t=10316154&page=2

and I was testing some of their suggestions.

 

I applied your suggestion and then got the same message that I just told Bauer418 about....

The following is all of the latest code.  Don't forget.. I'm a beginner.. this is my first one.. it has been gutted and rebuilt many times.

The most current error message is:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /mnt/w0202/d07/s47/b021cdb1/www/3view.php on line 92

 

Line 92 is: if (mysql_num_rows($query)) {

 

 

Latest Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

 

<body>

<?php

$username = "****";

$password = "****";

$hostname = "MYSQLHOST";

 

$dbhandle = mysql_connect($hostname, $username, $password)

  or die("Unable to connect to MySQL");

 

$selected = mysql_select_db("******",$dbhandle)

  or die("Could not select *******");

 

 

$id = $_GET['id'];

 

$query = mysql_query("SELECT a.strLodgeName, a.intLodgeNumber, a.strDistrictName, a.strLodgeWEB, a.strLodgeCounty, a.dtChartered, a.strLodgeMailingAddress, a.strLodgeMailingAddress2, a.strLodgeMailingCity, a.strLodgeMailingPostCode, a.strLodgeEmail, a.strLodgePhone, a.strLodgeFax, a.strDrivingDirectons, a.dtMeetingTime, a.dtMealTime, a.strFloorSchool, a.strLodgeNews, b.strOfficerTitle, b.strFirstName, b.strLastName, b.BusinessPhone, b.PersEmail FROM tblLodges a LEFT JOIN tblOfficers b ON a.lngLodgeID = b.lngLodgeID WHERE a.intLodgeNumber=$id GROUP BY a.strLodgeName LIMIT 50");

while ($row = @mysql_fetch_array($query))

 

{

$variable1=$row["strLodgeName"];

$variable2=$row["intLodgeNumber"];

$variable3=$row["strDistrictName"];

$variable4=$row["strLodgeWEB"];

$variable5=$row["strLodgeCounty"];

$variable6=$row["dtChartered"];

$variable7=$row["strLodgeMailingAddress"];

$variable8=$row["strLodgeMailingAddress2"];

$variable9=$row["strLodgeMailingCity"];

$variable10=$row["strLodgeMailingStateCode"];

$variable11=$row["strLodgeMailingPostCode"];

$variable12=$row["strLodgeEmail"];

$variable13=$row["strLodgePhone"];

$variable14=$row["strLodgeFax"];

$variable15=$row["strDrivingDirectons"];

$variable16=$row["dtMeetingTime"];

$variable17=$row["dtMealTime"];

$variable18=$row["strFloorSchool"];

$variable19=$row["strLodgeNews"];

$variable20=$row["link"];

//table layout for results

 

echo ("<tr>");

echo "<center>\n";

echo "<p>GRAND LODGE OF LOUISIANA - LODGE LOCATOR RESULTS\n</p>";

echo "Lodge Name: $variable1</p>";

echo "<p><b>Lodge Number:</b> $variable2</p>";

echo "<p><b>District Name:</b> $variable3</p>";

echo "<a href=\"$variable4\">Click Here To Go To The Lodge Website</a>";

echo "<p><b>Lodge County:</b> $variable5</p>";

echo "<p><b>Lodge Chartered On:</b> $variable6</p>";

echo "<p><b>Lodge Address:</b> $variable7, $variable8</p>";

echo '<p>' . $variable9 . $variable10 . $variable11 . '</p>';

echo "Click Here To Email The Lodge";

echo "<p>Lodge Phone Number: $variable13, Lodge FAX Number: $variable14</p>";

echo "<p>Lodge Driving Directions: $variable15</p>";

echo "<p>Lodge Lodge Meeting Time: $variable16</p>";

echo "<p>Lodge Lodge Meal Time: $variable17</p>";

echo "<p>Lodge Floor School: $variable18</p>";

echo "<p>Lodge News: $variable19</p>";

echo "<img src='{$row['link']}'>";

echo "</center>\n";

echo ("</tr>");

}

?> </tr>

</table>

<hr width=75% align=center size=4>

 

 

<?php

//query details table begins

$query = mysql_query("SELECT tblLodges.strLodgeName, tblLodges.intLodgeNumber, tblLodges.strDistrictName, tblLodges.strLodgeMailingCity, tblLodges.strLodgeMailingPostCode, tblLodges.strLodgeCounty, tblOfficers.strOfficerTitle, tblOfficers.strFirstName, tblOfficers.strLastName, tblOfficers.BusinessPhone, tblOfficers.PersEmail FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' LIMIT 0, 50");

 

echo "<center>\n";

echo "<H2>Roster of Lodge Officers</H2>\n";

echo "<table border='1'>

  <tr>

<th>Officer Title</th>

<th>Officer First</th>

<th>Officer Last</th>

<th>Officer Email</th>

<th>Officer Phone</th>

 

</tr>";

 

if (mysql_num_rows($query)) {

    while ($row = mysql_fetch_array($query)) {

        $variable1=$row["strOfficerTitle"];

        $variable2=$row["strFirstName"];

        $variable3=$row["strLastName"];

        $variable4=$row["PersEmail"];

        $variable5=$row["BusinessPhone"];

       

        //table layout for results

       

        print("<tr>");

        echo "<tr align=\"center\" bgcolor=\"#EFEFEF\">\n";

        echo "<td class=\"td_id\">$variable1</td>\n";

        echo "<td class=\"td_id\">$variable2</td>\n";

        echo "<td class=\"td_id\">$variable3</td>\n";

        echo "<td class=\"td_id\">$variable4</td>\n";

        echo "<td class=\"td_id\">$variable5</td>\n";

        print("</tr>");

    }

}

?>

</body>

</html>

Put a die at the end of your queries, like this:

 

<?php

$query = mysql_query("SELECT tblLodges.strLodgeName, tblLodges.intLodgeNumber, tblLodges.strDistrictName, tblLodges.strLodgeMailingCity, tblLodges.strLodgeMailingPostCode, tblLodges.strLodgeCounty, tblOfficers.strOfficerTitle, tblOfficers.strFirstName, tblOfficers.strLastName, tblOfficers.BusinessPhone, tblOfficers.PersEmail FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' LIMIT 0, 50")or die(mysql_error());

I'm not sure what you mean... but I've been in this code for so long.. I'm helpless at this point.

Here is the whole thing in action:

 

http://www.la-mason.com/3search.html

 

Search for "Zip Code" and put in 71129

 

Now click one of the "View" buttons - and you are now seeing the code we have been working on.

There is supposed to be a table at the bottom of the page listing Officer Titles, Names, Emails and Phone

Well, the good news is I'm getting a chart at the bottom of my page showing names/titles/emails and phone numbers.

The bad news is the data  doesn't match the lodge info above the table.

I have a Lodges table and an Officers table they are connected via the 'lngLodgeID' field.

 

I'm sooo close to leaving you guys alone.. 

 

I'm now wondering if I can remove that entire 2nd query and pull this tblOfficers table from the first query?

 

I tried to troubleshoot my own problem - yes, I actually do this  ;)

And I discovered it is probably the way I need to go.  Everything looks great with the exception of one minor thing - the table at the bottom of the page is only returning one person when there are 2-3 people attached to each lodge.

 

The following is all of my code.. can you glance at it for me?

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

 

<body>

<?php

$username = "*****";

$password = "*****";

$hostname = "MYSQLHOST";

 

$dbhandle = mysql_connect($hostname, $username, $password)

  or die("Unable to connect to MySQL");

 

$selected = mysql_select_db("*****",$dbhandle)

  or die("Could not select *******");

 

 

$id = $_GET['id'];

 

$query = mysql_query("SELECT a.strLodgeName, a.intLodgeNumber, a.strDistrictName, a.strLodgeWEB, a.strLodgeCounty, a.dtChartered, a.strLodgeMailingAddress, a.strLodgeMailingAddress2, a.strLodgeMailingCity, a.strLodgeMailingPostCode, a.strLodgeEmail, a.strLodgePhone, a.strLodgeFax, a.strDrivingDirectons, a.dtMeetingTime, a.dtMealTime, a.strFloorSchool, a.strLodgeNews, b.strOfficerTitle, b.strFirstName, b.strLastName, b.BusinessPhone, b.PersEmail FROM tblLodges a LEFT JOIN tblOfficers b ON a.lngLodgeID = b.lngLodgeID WHERE a.intLodgeNumber=$id GROUP BY a.strLodgeName LIMIT 50")or die(mysql_error());

while ($row = @mysql_fetch_array($query))

 

{

$variable1=$row["strLodgeName"];

$variable2=$row["intLodgeNumber"];

$variable3=$row["strDistrictName"];

$variable4=$row["strLodgeWEB"];

$variable5=$row["strLodgeCounty"];

$variable6=$row["dtChartered"];

$variable7=$row["strLodgeMailingAddress"];

$variable8=$row["strLodgeMailingAddress2"];

$variable9=$row["strLodgeMailingCity"];

$variable10=$row["strLodgeMailingStateCode"];

$variable11=$row["strLodgeMailingPostCode"];

$variable12=$row["strLodgeEmail"];

$variable13=$row["strLodgePhone"];

$variable14=$row["strLodgeFax"];

$variable15=$row["strDrivingDirectons"];

$variable16=$row["dtMeetingTime"];

$variable17=$row["dtMealTime"];

$variable18=$row["strFloorSchool"];

$variable19=$row["strLodgeNews"];

$variable20=$row["strOfficerTitle"];

$variable21=$row["strFirstName"];

$variable22=$row["strLastName"];

$variable23=$row["BusinessPhone"];

$variable24=$row["PersEmail"];

 

//table layout for results

 

echo ("<tr>");

echo "<center>\n";

echo "<p>GRAND LODGE OF LOUISIANA - LODGE LOCATOR RESULTS\n</p>";

echo "Lodge Name: $variable1</p>";

echo "<p><b>Lodge Number:</b> $variable2</p>";

echo "<p><b>District Name:</b> $variable3</p>";

echo "<a href=\"$variable4\">Click Here To Go To The Lodge Website</a>";

echo "<p><b>Lodge County:</b> $variable5</p>";

echo "<p><b>Lodge Chartered On:</b> $variable6</p>";

echo "<p><b>Lodge Address:</b> $variable7, $variable8</p>";

echo '<p>' . $variable9 . $variable10 . $variable11 . '</p>';

echo "Click Here To Email The Lodge";

echo "<p>Lodge Phone Number: $variable13, Lodge FAX Number: $variable14</p>";

echo "<p>Lodge Driving Directions: $variable15</p>";

echo "<p>Lodge Lodge Meeting Time: $variable16</p>";

echo "<p>Lodge Lodge Meal Time: $variable17</p>";

echo "<p>Lodge Floor School: $variable18</p>";

echo "<p>Lodge News: $variable19</p>";

echo "<img src='{$row['link']}'>";

echo "</center>\n";

echo ("</tr>");

}

 

//query details table begins

 

echo "<center>\n";

echo "<H2>Roster of Lodge Officers</H2>\n";

echo "<table border='1'>

  <tr>

<th>Officer Title</th>

<th>Officer First</th>

<th>Officer Last</th>

<th>Officer Email</th>

<th>Officer Phone</th>

 

</tr>";

 

        //table layout for results

       

        print("<tr>");

        echo "<tr align=\"center\" bgcolor=\"#EFEFEF\">\n";

        echo "<td class=\"td_id\">$variable20</td>\n";

        echo "<td class=\"td_id\">$variable21</td>\n";

        echo "<td class=\"td_id\">$variable22</td>\n";

        echo "<td class=\"td_id\">$variable23</td>\n";

        echo "<td class=\"td_id\">$variable24</td>\n";

        print("</tr>");

?>

</body>

</html>

 

 

If your talking abbout

 

        print("<tr>");
        echo "<tr align=\"center\" bgcolor=\"#EFEFEF\">\n";
        echo "<td class=\"td_id\">$variable20</td>\n";
        echo "<td class=\"td_id\">$variable21</td>\n";
        echo "<td class=\"td_id\">$variable22</td>\n";
        echo "<td class=\"td_id\">$variable23</td>\n";
        echo "<td class=\"td_id\">$variable24</td>\n";
        print("</tr>");

 

It would help to have it in the while loop lol

I'm not sure what that means...?

 

Also, now - OUT OF NOWHERE - I have a new error message - Should I start a new thread?

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY a.strLodgeName LIMIT 50' at line 1

It's kind of hard helping you with comunication problems hehe

 

if this

 

        print("<tr>");
       echo "<tr align=\"center\" bgcolor=\"#EFEFEF\">\n";
       echo "<td class=\"td_id\">$variable20</td>\n";
       echo "<td class=\"td_id\">$variable21</td>\n";
       echo "<td class=\"td_id\">$variable22</td>\n";
       echo "<td class=\"td_id\">$variable23</td>\n";
       echo "<td class=\"td_id\">$variable24</td>\n";
       print("</tr>");

 

the part only showing one result?

 

If yes it's most likly because it's not in the wile loop

 

This is the while ($row = @mysql_fetch_array($query))

 

{

 

and it ends by }

Put the code before the } if you would like it to be looped changed at every new rows

 

What did you change to the query?

Forgive my ignorance.. I'm just spankin' new at this stuff.

I think I understand.. but I can't test it until I get this new GROUP BY? error message resolved.  The code now looks like this:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

 

<body>

<?php

$username = "*****";

$password = "*****";

$hostname = "MYSQLHOST";

 

$dbhandle = mysql_connect($hostname, $username, $password)

  or die("Unable to connect to MySQL");

 

$selected = mysql_select_db("*****",$dbhandle)

  or die("Could not select ******");

 

 

$id = $_GET['id'];

 

$query = mysql_query("SELECT a.strLodgeName, a.intLodgeNumber, a.strDistrictName, a.strLodgeWEB, a.strLodgeCounty, a.dtChartered, a.strLodgeMailingAddress, a.strLodgeMailingAddress2, a.strLodgeMailingCity, a.strLodgeMailingPostCode, a.strLodgeEmail, a.strLodgePhone, a.strLodgeFax, a.strDrivingDirectons, a.dtMeetingTime, a.dtMealTime, a.strFloorSchool, a.strLodgeNews, b.strOfficerTitle, b.strFirstName, b.strLastName, b.BusinessPhone, b.PersEmail FROM tblLodges a LEFT JOIN tblOfficers b ON a.lngLodgeID = b.lngLodgeID WHERE a.intLodgeNumber=$id GROUP BY a.strLodgeName LIMIT 50")or die(mysql_error());

while ($row = @mysql_fetch_array($query))

 

{

$variable1=$row["strLodgeName"];

$variable2=$row["intLodgeNumber"];

$variable3=$row["strDistrictName"];

$variable4=$row["strLodgeWEB"];

$variable5=$row["strLodgeCounty"];

$variable6=$row["dtChartered"];

$variable7=$row["strLodgeMailingAddress"];

$variable8=$row["strLodgeMailingAddress2"];

$variable9=$row["strLodgeMailingCity"];

$variable10=$row["strLodgeMailingStateCode"];

$variable11=$row["strLodgeMailingPostCode"];

$variable12=$row["strLodgeEmail"];

$variable13=$row["strLodgePhone"];

$variable14=$row["strLodgeFax"];

$variable15=$row["strDrivingDirectons"];

$variable16=$row["dtMeetingTime"];

$variable17=$row["dtMealTime"];

$variable18=$row["strFloorSchool"];

$variable19=$row["strLodgeNews"];

$variable20=$row["strOfficerTitle"];

$variable21=$row["strFirstName"];

$variable22=$row["strLastName"];

$variable23=$row["BusinessPhone"];

$variable24=$row["PersEmail"];

 

//table layout for results

 

echo ("<tr>");

echo "<center>\n";

echo "<p>GRAND LODGE OF LOUISIANA - LODGE LOCATOR RESULTS\n</p>";

echo "<p><b>Lodge Name:</b> $variable1</p>";

echo "<p><b>Lodge Number:</b> $variable2</p>";

echo "<p><b>District Name:</b> $variable3</p>";

echo "<a href=\"$variable4\">Click Here To Go To The Lodge Website</a>";

echo "<p><b>Lodge County:</b> $variable5</p>";

echo "<p><b>Lodge Chartered On:</b> $variable6</p>";

echo "<p><b>Lodge Address:</b> $variable7, $variable8</p>";

echo '<p>' . $variable9 . $variable10 . $variable11 . '</p>';

echo "<a href=mailto:\"$variable12\">Click Here To Email The Lodge</a>";

echo "<p><b>Lodge Phone Number:</b> $variable13, <b>Lodge FAX Number:</b> $variable14</p>";

echo "<p><b>Lodge Driving Directions:</b> $variable15</p>";

echo "<p><b>Lodge Lodge Meeting Time:</b> $variable16</p>";

echo "<p><b>Lodge Lodge Meal Time:</b> $variable17</p>";

echo "<p><b>Lodge Floor School:</b> $variable18</p>";

echo "<p><b>Lodge News:</b> $variable19</p>";

echo "<img src='{$row['link']}'>";

echo "</center>\n";

echo ("</tr>");

}

 

//query details table begins

 

echo "<center>\n";

echo "<H2>Roster of Lodge Officers</H2>\n";

echo "<table border='1'>

  <tr>

<th>Officer Title</th>

<th>Officer First</th>

<th>Officer Last</th>

<th>Officer Email</th>

<th>Officer Phone</th>

 

</tr>";

 

        //table layout for results

       

        print("<tr>");

        echo "<tr align=\"center\" bgcolor=\"#EFEFEF\">\n";

        echo "<td class=\"td_id\">$variable20</td>\n";

        echo "<td class=\"td_id\">$variable21</td>\n";

        echo "<td class=\"td_id\">$variable22</td>\n";

        echo "<td class=\"td_id\">$variable23</td>\n";

        echo "<td class=\"td_id\">$variable24</td>\n";

        print("</tr>");

?>

</body>

</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.