Hi,
I don't have any idea on this error:


Object of class variant could not be converted to string.

I am facing the error in this block.Please have a look on this:


IF($g!="P")
       {
          mssql_close($dbhandle);
	 //*** Close & Quit ***//  
	 $excel_app->Application->Quit();  
	 $excel_app = null;  
         $Workbook = null;  
         $Worksheet = null; 
         
         if (file_exists("$uploadedfilepath"))
         {
             #delete
             unlink($uploadedfilepath) or die ("Could not delete file"); 
         }
          [I]exit("error in uploading"."  ".$idno)	                   
[/I]
       }


I don't have idea in this error. Please help me out.Thanks in advance

Recommended Answers

All 8 Replies

What is $g? Probably an object ("object of class variant"). You'll need to think of what you actually want to know. Also, don't die if you can't delete a file. You die anyway, and you already know your file exists.

Hi,

$g is a variable. (ie $g="P" ). If this condition is satisfied...i am trying to close db connection and at the same time "deleting my files".

I am facing this error, mainly from EXIT FUNCTION. I don't why?
1. Closing db connection
2. deleting my files from a directory
3. using EXIT FUNCTION - to stop script. (problem here only)

and i tried this also, if i am using only EXIT FUNCTION (Without using Closing db connection and deleting my files from a directory)means, i am not facing this error..

and i too tried this also, if i replace EXIT FUNCTION as my first step and then remaining two follows this. Then also, i am facing this error.

Yes, but what's in it? Obviously, php isn't happy with it. Or is the problem the $idno variable? In what line is the error anyway?

hi,

the error line is in the exit() function.How you telling the error is due to $idno variable. May be due to this also, what u told ? But i did not tried this.

I think so, not due to $idno. If i place, as the first statement in the IF LOOP and then remaining two things are following(db close and file deletion) and then also i am facing this same error.help me out

Can you try to replace $idno with any number (2, or 3, ..) and try if you get an error? Also, place var_dump($idno); before that line and post what it gives you?

Hi,

IF($g!="P")[/B]
       {
          mssql_close($dbhandle);
	 //*** Close & Quit ***//  
	 $excel_app->Application->Quit();  
	 $excel_app = null;  
         $Workbook = null;  
         $Worksheet = null; 
         
         if (file_exists("$uploadedfilepath"))
         {
             #delete
             unlink($uploadedfilepath) or die ("Could not delete file"); 
         }
          exit("error in uploading"."  ".$idno)	                   

       }

while printing:
echo var_dump($g)


my output is
object(variant)#7

But my $g is a string.
How to make it to string variable. My IF FUCNCTION also gets failed.help me out

How do you assign it? $p='P'; should work, generally.

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.