RE: [PHP] Problems with PHP and MySQL Code
| From: | Lawrence dot Sheed at dfait-maeci dot gc dot ca | Date: | Tue, 31 Oct 2000 06:35:27 +0000 |
| Subject: | RE: [PHP] Problems with PHP and MySQL Code | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-22862@lists.php.net to get a copy of this message | ||
Firstly give us some error messages.
Secondly
$cconnection = @mysql_connect("localhost", "theplayspot", "password")
or die("Couldn't connect.");
$db = @mysql_select_db($db_name, $connection)
$cconnection in first line
$connection in second
Try changing $cconnection in the first line.
eg
$connection = @mysql_connect("localhost", "theplayspot", "password")
or die("Couldn't connect.");
-----Original Message-----
From: Austin Carpenter [mailto:phprocks9000@hotmail.com]
Sent: October 31, 2000 11:45 AM
To: php-general@lists.php.net
Subject: [PHP] Problems with PHP and MySQL Code
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.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net