unable to insert values in database

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
anaspk
Forum Newbie
Posts: 7
Joined: Wed Mar 25, 2009 1:38 am

unable to insert values in database

Post 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);
}
?>
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: unable to insert values in database

Post 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.
Post Reply