قواعد البيانات
الفصل الخامس
</form>
<?php
$dcn=@mysql_connect ("localhost", "root", ""); if (! $dcn) {
echo ("<p> Can not connect to server </p>"); exit();
}
if (! @mysql_select_db("wise"))
{
echo ("<p> Can not connect to database </p>");
exit ();
}
if ($submitwise
==
"Add") {
$sql = "Insert into wise set wisetext = '$wisetext', wisename ='$wisename',wisedate=curdate()" ;
if (mysql_query($sql)) {
echo ("<p> Comment added <</p>");
} else {
echo ("<p> Error: ". mysql_error() . "</p>") ;
}
}
echo ("<p> All Comments </p>");
$result = mysql_query("select * from wise");
if (! $result) {
echo ("<p> Error: ". mysql_error() . "</p>") ; exit();
}
while ($row=mysql_fetch_array($result)) { echo ("Name: ".$row [wisename]); echo (" Comment: ".$row [wisetext]); echo (" Date: ".$row [wisedate]. "<BR>");
}
191
ص ١٩١