Hi can anyone help me. I have an issue of converting an array object to string.Here is my code

if(isset($_REQUEST['insert']))
{

$data['first_name']=$_REQUEST['fnam'];
$data['last_name']=$_REQUEST['lnam'];
$data['reg_number']=$_REQUEST['rnum'];
$data['date_of_birth']=$_REQUEST['dobi'];
$data['date_of_joining']=$_REQUEST['dojo'];
$data['name']=$_FILES['uploadfile']['name'];// i want to convert only this value to string
$data['type']=$_FILES['uploadfile']['type'];
$data['size']=$_FILES['uploadfile']['size'];
echo http_build_query($data['name']); exit;
$uname=str_replace(" ","_",$data);
$tmp_name=$_FILES['uploadfile']['tmp_name'];
$target_path="uploads/";
$target_path=$target_path.basename($uname);

if($data['name']=="")
{
 $db->query_insert('tbl_student',$data);  
 header('');
}
if(move_uploaded_file($_FILES['uploadfile']['tmp_name'],$target_path))
{
//if (move_uploaded_file=$_FILES['upload file']['tmp_name'],$target_path)
 list($width,$height,$siz,$attr)=getimagesize($target_path);
 if($width>150||$height>200)
 {
 echo "Your image size has exceeded the maximum length please re-enter";?>
 Please <a href="">Click here</a>to return to the page
 <?php die(); ?>
 
  
<?php }
if($siz>350000)
{
echo "Size is too big"; ?>
 Please <a href="">Click here</a>to return to the page
<?php die();
}
if(!( $type=='image/jpeg' || $type=='image/png' || $type=='image/gif' ))
{
echo "Your input format is not valid";
?>
 Please <a href="">Click here</a>to return to the page
<?php die();
}

else
{
$db->query_insert('tbl_student',$data);  
 $result=mysql_query($sql);
 header('');
}
}

thanx in advance

At your specified line no 9, you will have the uploaded file name in string format only. What is your exact error message in your process..? Addtionally, please check by removing exit code from line 12. Suppose, it may be a problem by terminating the execution. I might be misunderstood, but if you tell me the error that you obtain correctly, then we will surely help you...

thanx i have solved my proble here is my new code

if(isset($_REQUEST['insert']))
{

$data['first_name']=$_REQUEST['fnam'];
$data['last_name']=$_REQUEST['lnam'];
$data['reg_number']=$_REQUEST['rnum'];
$data['date_of_birth']=$_REQUEST['dobi'];
$data['date_of_joining']=$_REQUEST['dojo'];
$data['name']=$_FILES['uploadfile']['name'];
$data['type']=$_FILES['uploadfile']['type'];
$data['size']=$_FILES['uploadfile']['size'];
//array_reduce($data,query_insert);
$uname=str_replace(" ","_",$data['name']);
$tmp_name=$_FILES['uploadfile']['tmp_name'];
$target_path="uploads/";
$target_path=$target_path.basename($uname);

if($data['name']=="")
{
 $db->query_insert('tbl_student',$data);  
 header('location:');
}
if(move_uploaded_file($_FILES['uploadfile']['tmp_name'],$target_path))
{
//if (move_uploaded_file=$_FILES['upload file']['tmp_name'],$target_path)
 list($width,$height,$siz,$attr)=getimagesize($target_path);
 if($width>150||$height>200)
 {
 echo "Your image size has exceeded the maximum length please re-enter";?>
 Please <a href="">Click here</a>to return to the page
 <?php die(); ?>
 
  
<?php }
if($siz>350000)
{
echo "Size is too big"; ?>
 Please <a href="">Click here</a>to return to the page
<?php die();
}
if(!( $data['type']=='image/jpeg' || $dta['type']=='image/png' || $data['type']=='image/gif' ))
{
echo "Your input format is not valid";
?>
 Please <a href="">Click here</a>to return to the page
<?php die();
}

else
{
$db->query_insert('tbl_student',$data);  
 $result=mysql_query($sql);
 header('location:');
}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.