HighDots Forums  

insert into table problems

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss insert into table problems in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
adzir
 
Posts: n/a

Default 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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.