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);
}
?>
unable to insert values in database
Moderator: General Moderators
Re: unable to insert values in database
@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]
see if anything turns up.. The mysql error will be displayed if your query hasnt been executed properly.
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();
}