I need help ... can someone help me check for errors

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
bolaji
Forum Newbie
Posts: 1
Joined: Sun Dec 28, 2003 1:13 pm
Contact:

I need help ... can someone help me check for errors

Post by bolaji »

I have these codes on my site but they are not retrieving anything from the mysql database nore ids the php page showing anything. Please are there any errors there:

This one checks for birthday celebrants of the day (there is a Month and Day column in the table in 2 digit format):

<html>

<head>
<title>LVCU Member Database</title>
</head>

<body link="#000080" vlink="#008000" alink="#008000" bgproperties="fixed" background="lvcuback.jpg">

<?php
$scriptdt = Now();
<p><font face="Trebuchet MS" font size="3"><b>
Today is echo "$scriptdt";
</b></font></p>

$db = mysql_connect("localhost", "mydbname", "mydbpassword");
if (!$db) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
mysql_select_db("lvcudb",$db);

$dt = Now();
$mth = date('%m', $dt);
$dy = date('%d', $dt);


$result = mysql_query("SELECT * FROM members WHERE Month=$mth AND Day=$dy",$db);

echo "<DIV ALIGN="CENTER">";
echo "<CENTER>";
echo "<TABLE BORDER=2>";
echo "<font face="Trebuchet MS" size="2">";
echo"<TR><TD><B>ID</B><TD><B>Surname</B><TD><B>Other_Name</B><TD><B>Sex</B><TD><B>Birthday</B><TD><B>Status</B></TR>";

while ($myrow = mysql_fetch_array($result))
{
echo "<TR><TD>";
echo $myrow["ID"];
echo "<TD>";
echo $myrow["Surname"];
echo "<TD>";
echo $myrow["Other_Name"];
echo"<TD>";
echo $myrow["Sex"];
echo "<TD>";
echo $myrow["Day"];
echo "<TD>";
echo $myrow["Data1"];
}
echo "</font>";
echo "</TABLE>";
echo "</CENTER>";
echo "</DIV>";

?>

</body>
</html>


This one retrives members of a particular family from the database (the string $searchstringf is posted from another page)


<html>

<head>
<title>LVCU Member Database</title>
</head>

<body link="#000080" vlink="#008000" alink="#008000" bgproperties="fixed" background="lvcuback.jpg">


<?php

$db = @mysql_connect("localhost", "mydbusername", "mydbpassword");
if (!$db) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}

mysql_select_db("lvcudb",$db);
$result = mysql_query("SELECT * FROM members WHERE Family LIKE '%" . $_POST['searchstringf'] . "%' ORDER BY Surname",$db);
echo "<DIV ALIGN="CENTER">";
echo "<CENTER>";
echo "<TABLE BORDER=2>";
echo "<font face="Trebuchet MS" size="2">";
echo"<TR><TD><B>ID</B><TD><B>Surname</B><TD><B>Other_Name</B><TD><B>Sex</B><TD><B>Status</B></TR>";

while ($myrow = mysql_fetch_array($result))
{
echo "<TR><TD>";
echo $myrow["Surname"];
echo "<TD>";
echo $myrow["Other_Name"];
echo "<TD>";
echo $myrow["Sex"];
echo "<TD>";
echo $myrow["Data1"];
}
echo "</font>";
echo "</TABLE>";
echo "</CENTER>";
echo "</DIV>";

?>

</body>
</HTML>

Please help fing the errors in this
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: I need help ... can someone help me check for errors

Post by Weirdan »

bolaji wrote:<p><font face="Trebuchet MS" font size="3"><b>
Today is echo "$scriptdt";
</b></font></p>

$db = mysql_connect("localhost", "mydbname", "mydbpassword");
At least change that lines to something like:

Code: Select all

?>
<p><font face="Trebuchet MS" font size="3"><b>
Today is <?php echo "$scriptdt"; ?>
</b></font></p>

<?php
$db = mysql_connect("localhost", "mydbname", "mydbpassword");
Post Reply