Problems with PHP and MySQL Code

From: Date: Tue, 31 Oct 2000 03:45:22 +0000
Subject: Problems with PHP and MySQL Code
Groups: php.general 
Request: Send a blank email to php-general+get-22844@lists.php.net to get a copy of this message
Hi, Anyone happen to know why the following isn't working? $cconnection = @mysql_connect("localhost", "theplayspot", "password") or die("Couldn't connect."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database."); $sql = "AVG(rating) from $tablename2 "; $result = @mysql_query($sql,$connection) or die("Couldn't execute query."); $row = mysql_fetch_array($result); $average = $row[0]; $connection = @mysql_connect("localhost", "theplayspot", "password") or die("Couldn't connect."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database."); $sql = "COUNT(*) from $tablename2 "; $result = @mysql_query($sql,$connection) or die("Couldn't execute query."); $row = mysql_fetch_array($result); $numberofreviews = $row[0]; And, why this loop doesn't seem to be working? $sql = "SELECT fname, lname, email, level, id, date, rating, homeriver, strengths, location, weaknesses, summary, style, productyear, productexperience, similar FROM $tablename2 WHERE id = $id "; while ($row = mysql_fetch_array($result)) { $fname = $row['fname']; $lname = $row['lname']; $email = $row['email']; $level = $row['level']; $id = $row['id']; $date = $row['date']; $rating = $row['rating']; $homeriver = $row['homeriver']; $strengths = $row['strengths']; $weaknesses = $row['weaknesses']; $summary = $row['summary']; $style = $row['style']; $productyear = $row['productyear']; $productexperience = $row['productexperience']; $similar = $row['similar']; $name = $fname." ".$lname; if ($date == "0000-00-00") { $date = "[unknown]"; } $ratingphoto = "/rating".$rating.".gif"; $display_block = ' <table bgcolor=\"#ffffff\" width=75%> <tr> <td width=\"75%\" height=\"30\" colspan=\"2\" align=\"left\" valign=\"middle\" bgcolor=\"#85b2ad\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\"> <font face=\"verdana, arial, helvetica\" size=\"-1\"> Submitted by
						    <b><A HREF=\"mailto:<? echo $email; ?> \"><? echo $name; ?></A>
a <? echo $style; ?> Kayaker
				             from <? echo location; ?>
<br>Date Reviewed: <b><? echo date; ?></b> </font> </td> </tr> <tr> <td width=\"20%\" align=\"left\" valign=\"top\" bgcolor=\"#efefdf\"><font face=\"verdana, arial, helvetica\" size=\"-1\"> <b>Home River:</b></font></td> <td width=\"100%\" align=\"left\" valign=\"top\" bgcolor=\"#efefdf\"><font face=\"verdana, arial, helvetica\" size=\"-1\"><? echo $homeriver; ?></font></td> </tr> <tr> <td width=\"20%\" align=\"left\" valign=\"top\" bgcolor=\"#efefdf\"><font face=\"verdana, arial, helvetica\" size=\"-1\"> <b>Product Experience:</b></font></td> <td width=\"100%\" align=\"left\" valign=\"top\" bgcolor=\"#efefdf\"><font face=\"verdana, arial, helvetica\" size=\"-1\"><? echo $productexperience; ?></font></td> </tr> <tr> <td width=\"20%\" align=\"left\" valign=\"top\" bgcolor=\"#efefdf\"><font face=\"verdana, arial, helvetica\" size=\"-1\"> <b>Strengths:</b></font></td> <td width=\"100%\" align=\"left\" valign=\"top\" bgcolor=\"#efefdf\"><font face=\"verdana, arial, helvetica\" size=\"-1\"><? echo $strengths: ?></font></td> </tr> <tr> <td width=\"20%\" align=\"left\" valign=\"top\" bgcolor=\"#efefdf\"><font face=\"verdana, arial, helvetica\" size=\"-1\"> <b>Weaknesses:</b></font></td> <td width=\"100%\" align=\"left\" valign=\"top\" bgcolor=\"#efefdf\"><font face=\"verdana, arial, helvetica\" size=\"-1\"><? echo $weaknesses; ?></font></td> </tr> <tr> <td width=\"20%\" align=\"left\" valign=\"top\" bgcolor=\"#efefdf\"><font face=\"verdana, arial, helvetica\" size=\"-1\"> <b>Similar Products Tried:</b></font></td> <td width=\"100%\" align=\"left\" valign=\"top\" bgcolor=\"#efefdf\"><font face=\"verdana, arial, helvetica\" size=\"-1\"><? echo $similar; ?><BR></font></td> </tr> <tr> <td width=\"20%\" align=\"left\" valign=\"top\" bgcolor=\"#efefdf\"><font face=\"verdana, arial, helvetica\" size=\"-1\"> <b>Summary:</b></font></td> <td width=\"100%\" align=\"left\" valign=\"top\" bgcolor=\"#efefdf\"><font face=\"verdana, arial, helvetica\" size=\"-1\"><? echo $summary; ?></font></td> </tr> <tr> <td colspan=2 width=\"100%\" align=\"left\" valign=\"middle\" bgcolor=\"#efefdf\"> <font face=\"verdana, arial, helvetica\" size=\"-1\"> <b>Overall Rating:</b> <img src="<? echo $ratingphoto; ?>" alt="5" border="0" align=center> </font> </td> </tr> </table> <br> '; } I have been working on this for a long time and can't figure it out :(. I am guessing it is something easy and obvious. Thanks for the help in advance. Thanks, Austin Carpenter _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Share information about yourself, create your own public profile at http://profiles.msn.com.

« previous php.general (#22844) next »