insert into table problems -
04-05-2006
, 12:06 AM
Hi,
somebody help my lecturer given my only 5 days to complete this simple
student registration system using PHP. I chose dreamweaver as the tool
When it comes to this point...insert I got problems. Data is POSTed
from previous page
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("StudentReg",$db);
//To insert selections from the subjectreg.php page into table
resultinfo---------------------------//
echo "INSERT INTO resultinfo (ResultID, MatrixID, SubjectCode,
SemYear) VALUES
(".mysql_insert_id($db).",'".$_POST['textfield']."','".$_POST['select2']."',".settype($_POST['select'],"int").")";
$query = "INSERT INTO resultinfo (MatrixID, SubjectCode, SemYear)
VALUES
('".$_POST['textfield']."','".$_POST['select2']."','".settype($_POST['select'],"int")."')";
$result = mysql_query($query,$db);
if($result)
echo "<br>Insert have no problems<br>";
else
echo "<br>Insert have some problems<br>";
the insert was not successful.
and for this line
//get query from resultinfo for newly registered subject
$getresult = "select * from resultinfo where MatrixID =
".$_POST['textfield']." AND SemYear = '".$_POST['select']."'";
$result1 = mysql_query($getresult,$db);
$num = mysql_num_rows($result1);
?>
<table width="608" border="1">
<?php
for ($i=0; $i<$num; $i++)
{
$row1 = mysql_fetch_array($result1);
echo "<tr>";
echo "<td width=\"33\">".($i+1)."</td>";
echo "<td width=\"164\">".$row1["SubjectCode"]."</td>";
echo "<td width=\"275\">".$row1["SemYear"]."</td>";
echo "</tr>";
}
?>
</table>
i got warning: Warning: mysql_num_rows(): supplied argument is not a
valid MySQL result resource in c:\phpdev5\www\unikl\subregistered.php
on line 35
pls help! I'm desperate |