Thanks alot for your help! That was very careless of me..;p I was stil quite a
newbie to php-db coding...
By the way one last favour to ask of u hope u dun mind...
I have a script which was used to INSERT data into the database:
(See script below):
But everytime when I execute it I got the error "DB constraint"
I think the problem lies here:
$sql = "INSERT INTO tutor (tutor_name, tutor_contact, tutor_email,
tutor_profile)
VALUES ($tutor_name,$tutor_contact,$tutor_email,$tutor_profile)";
Whenever I single quote the string value:
VALUES ($tutor_name','$tutor_contact','$tutor_email','$tutor_profile')";
it actually insert a NULL value into the DB though I did enter values into the
text field.But if I dun quote it, I got the error:
"DB constraint". By right I ought to quote it right??
I have gone thru my code umpteen times but to no avail.
Where have i gone wrong??? ;(
-------------------------------------------------------------------------------
$dsn = "mysql://root:[EMAIL PROTECTED]/table1";
$db = DB::connect ($dsn);
if (DB::isError ($db))
die ($db->getMessage());
//create variables ready to go into DB
$tutor_name = $db->quote($_POST["tutor_name"]);
$tutor_contact = $db->quote($_POST["tutor_contact"]);
$tutor_email = $db->quote($_POST["tutor_email"]);
$tutor_profile = $db->quote($_POST["tutor_profile"]);
$sql = "INSERT INTO tutor (tutor_name, tutor_contact, tutor_email,
tutor_profile)
VALUES ($tutor_name,$tutor_contact,$tutor_email,$tutor_profile)";
$result = $db->query($sql);
if( DB::isError($result) ) {
die ($result->getMessage());
}
?><HTML>
<head>
<title>Add Tutor</title>
<!-- **************************CSS and HTML************************** -->
</head>
<body>
<div align="center">
<div id="pagecontent5">
<?php if( $_POST["submit"] != "Save" )
{
?>
<div align="center">
<form name="classinfo" action="<?php echo $_SERVER["PHP_SELF"]; ?>"
method="post">
<input type="hidden" name=form_submitted" value="1">
<table name="add_tutor" border=0px cellpadding="0" cellspacing="2"
width="900"><tr>
<td class="lighter" width="200">Name:</td>
<td class="lighter" width="500"><Input type="text" size="50"
name="tutor_name"></td>
</tr>
<tr>
<td class="darker" width="150">Contact No:</td>
<td class="darker" width="150"><Input type="text" size="30"
name="tutor_contact"></td>
</tr>
<tr>
<td class="lighter" width="150">Email:</td>
<td class="lighter" width="150"><Input type="text" size="50"
name="tutor_email"></td>
</tr>
<tr>
<td class="darker" width="150">Profile:</td>
<td class="darker" width="150"><TEXTAREA class="textarea"
NAME="tutor_profile" ROWS=6 COLS=70>
</TEXTAREA>
</td>
</tr>
<tr>
<td class="lighter" width="150"></td>
<td class="lighter" width="150"><a href="teacher_summary.php">
<div align="center"><input type="submit" name="submit"
value="Save"></div></a></td>
</tr>
</table>
</form>
<br>
<?php } else {?>
<table border=0">
<tr>
<td class="darker" width="300">Teacher:</td>
<td class="darker" width="600">
<?
echo $_POST["tutor_name"];
?>
</td>
</tr>
<tr><td class="lighter" width="300">Contact No:</td>
<td class="lighter" width="600">
<?
echo $_POST["tutor_contact"];
?>
</td>
</tr>
<tr>
<td class="darker" width="300">E-mail Address:</td>
<td class="darker" width="600">
<?
echo $_POST["tutor_email"];
?>
</td>
</tr>
<tr>
<td class="lighter" width="300">Profile:</td>
<td class="lighter" width="600">
<?
echo $_POST["tutor_profile"];
?>
</td>
</tr>
</body>
</html>
</div>
</div>
<?}?>
-------------------------------------------------------------------------------
(I'm terribly sorry if the code is kinda messy)
All help are greatly appreciated!
Irin.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php