Page 1 of 1

unable to insert values in database

Posted: Mon Apr 06, 2009 2:03 am
by anaspk
array $sub2 cant insert the values in a colum 'ord' of table order in the same database
<?php
include('datacon.php');
$sq1 = "SELECT regno FROM patientreg";
$result=mysql_query($sq1);
$num=mysql_num_rows($result);

for ($i=1; $i<=$num; $i++)
{
$row=mysql_fetch_array($result);
$val=$row['regno'];
$regno = $val;
$sub= substr($val,2);
$len=strlen($sub)-3;
$sub2= substr($sub,0,$len);
$sql2="INSERT INTO order(ord) VALUES('$sub2')";
echo $sub2."<br>";

//$sql2="UPDATE patientreg SET order = '$sub2' WHERE regno = '$regno'";
$query=mysql_query($sql2);
}
?>

Re: unable to insert values in database

Posted: Mon Apr 06, 2009 3:27 am
by susrisha
@editor/Moderator

Please change the location.. not pertaining to general discussion forum

@ anaspk
Try to post in the correct forum [php-code or databases forum]

Code: Select all

 
//put an error reporting statement here
if(!$query=mysql_query($sql2))
{
echo mysql_error();
}
 
see if anything turns up.. The mysql error will be displayed if your query hasnt been executed properly.