•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 455,964 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,609 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2056 | Replies: 7
![]() |
•
•
Join Date: Nov 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I have an Access database (yetch) from which I am retrieving a recordset. One of the text fields in the recordset has a few null values. I need to display all records (so I can't just eliminate these records in the SQL), but display a blank or alternative string for the null values.
If I try any string handling function on the null-valued variable, it chokes and gives me this:
Catchable fatal error: Object of class variant could not be converted to string in C:\Inetpub\wwwroot\Comed2005\category.php on line 193
I have no control over the database (long story), so I can't change the default value for the field.
I have tried inspecting the variable using empty() isset() is_null() ===null and a few other home-grown functions that I have found on other forums. None of these seem to be able to tell the difference between the null values, and those with something in them. I also tried using if(method_exists($fee, "__tostring")) but with no joy. The variables are all variant objects, and I can only tell which ones are null because all string functions choke on them.
Any suggestions gratefully received...
If I try any string handling function on the null-valued variable, it chokes and gives me this:
Catchable fatal error: Object of class variant could not be converted to string in C:\Inetpub\wwwroot\Comed2005\category.php on line 193
I have no control over the database (long story), so I can't change the default value for the field.
I have tried inspecting the variable using empty() isset() is_null() ===null and a few other home-grown functions that I have found on other forums. None of these seem to be able to tell the difference between the null values, and those with something in them. I also tried using if(method_exists($fee, "__tostring")) but with no joy. The variables are all variant objects, and I can only tell which ones are null because all string functions choke on them.
Any suggestions gratefully received...
•
•
Join Date: Oct 2006
Location: the Netherlands
Posts: 1,816
Reputation:
Rep Power: 11
Solved Threads: 189
empty() should work fine, could you post some code to explain where the problem is?
sample:
regards Niek
sample:
php Syntax (Toggle Plain Text)
if (!empty($row[0])) { $something = $row[0]; }
Want better/more replies to your questions? Wrap your code in [code] [/code] tags!
do NOT pm me for help, in the best case, you'll get ignored
do NOT pm me for help, in the best case, you'll get ignored
•
•
Join Date: Nov 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I agree Niek, empty() should work. But doesn't.
The code is:
which gives me the error:
Catchable fatal error: Object of class variant could not be converted to string in C:\Inetpub\wwwroot\Comed2005\category.php on line 193
Line 193 is the echo $Newfee line.
The code is:
$fee = $rs->Fields("Fee");
....
if (empty($fee)) {
$Newfee = "tba";
} else {
$Newfee=$fee;
}
....
echo $Newfee;which gives me the error:
Catchable fatal error: Object of class variant could not be converted to string in C:\Inetpub\wwwroot\Comed2005\category.php on line 193
Line 193 is the echo $Newfee line.
•
•
Join Date: Apr 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
I have an Access database (yetch) from which I am retrieving a recordset. One of the text fields in the recordset has a few null values. I need to display all records (so I can't just eliminate these records in the SQL), but display a blank or alternative string for the null values.
If I try any string handling function on the null-valued variable, it chokes and gives me this:
Catchable fatal error: Object of class variant could not be converted to string in C:\Inetpub\wwwroot\Comed2005\category.php on line 193
I have no control over the database (long story), so I can't change the default value for the field.
I have tried inspecting the variable using empty() isset() is_null() ===null and a few other home-grown functions that I have found on other forums. None of these seem to be able to tell the difference between the null values, and those with something in them. I also tried using if(method_exists($fee, "__tostring")) but with no joy. The variables are all variant objects, and I can only tell which ones are null because all string functions choke on them.
Any suggestions gratefully received...
Hi, I also have this problem, and wondered whether either a) you managed to fix it or b) whether someone out there knows how to resolve the problem.
Any help would be really appreciated...
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 636
Reputation:
Rep Power: 3
Solved Threads: 71
i think the item you are evaluating is an object and needs to converted to a string to be read like that.
maybe this will work (just a guess)
I have never had to do this so I don't know if it will work
maybe this will work (just a guess)
if (gettype($var) !== 'string') {
if (settype($var,"string")) {
echo $var . ' set to string';
}
else {
echo $var ' not able to be set to string';
}
}
//process variableI have never had to do this so I don't know if it will work
Last edited by kkeith29 : Apr 10th, 2008 at 11:14 am.
•
•
Join Date: Apr 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Hi, Thanks for replying with the suggestion. Unfortunately I get the same error on the following line:
I wonder whether the issue is due to the version of php I am running, and potentially the version of the libmysql.dll? As I did have a problem with the initial php installation (php-5.2.5-win32-installer.msi) when trying to access an access database. The resolution was to replace the installed libmysql.dll with the version contained within (php-5.2.1-Win32.zip).
Inserts, Updates, Selects all work fine for reference....
Thanks J
if (settype($rs->Fields('OR_DELIVERY_INSTRUCTIONS'),"string"))PHP Catchable fatal error: Object of class variant could not be converted to string in
I wonder whether the issue is due to the version of php I am running, and potentially the version of the libmysql.dll? As I did have a problem with the initial php installation (php-5.2.5-win32-installer.msi) when trying to access an access database. The resolution was to replace the installed libmysql.dll with the version contained within (php-5.2.1-Win32.zip).
Inserts, Updates, Selects all work fine for reference....
Thanks J
•
•
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 850
Reputation:
Rep Power: 2
Solved Threads: 66
The one thing that I have started doing and it seems to work very well for both blank strings and null values coming out of mysql and postgresql(haven't tried access) is:
php Syntax (Toggle Plain Text)
if(trim($row['value']) != "") { echo $row['value']; }
Last edited by R0bb0b : Jun 28th, 2008 at 4:17 pm.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Fatal Error (Windows NT / 2000 / XP / 2003)
- fatal error (PHP)
- how to select null values in condition (MySQL)
- Exception Data is Null. This method or property cannot be called on Null values. (VB.NET)
- Need help diplaying null values (PHP)
- Fatal Error Message When Accessing A Web Page (Windows NT / 2000 / XP / 2003)
- Fatal Error C010? (C)
- help with polymorphism and inheritance...getting null values (Java)
- fatal error C1010 (C++)
Other Threads in the PHP Forum
- Previous Thread: uploading photo problem
- Next Thread: Dinamic mailing list



Linear Mode