dan_t Posted May 1, 2010 Share Posted May 1, 2010 What exactly does it mean when you get this error when trying to insert data into a database? "Notice: Trying to get property of non-object" This was the line with the error. if($con->error) Link to comment https://forums.phpfreaks.com/topic/200343-error-message/ Share on other sites More sharing options...
trq Posted May 1, 2010 Share Posted May 1, 2010 It means what it says. Your trying to access a property of something that is not an object. Link to comment https://forums.phpfreaks.com/topic/200343-error-message/#findComment-1051378 Share on other sites More sharing options...
dan_t Posted May 1, 2010 Author Share Posted May 1, 2010 But it's just a connection, a connection is never an object is it? Link to comment https://forums.phpfreaks.com/topic/200343-error-message/#findComment-1051380 Share on other sites More sharing options...
trq Posted May 1, 2010 Share Posted May 1, 2010 So why are you treating it like an object? Where do you define $con? Link to comment https://forums.phpfreaks.com/topic/200343-error-message/#findComment-1051382 Share on other sites More sharing options...
dan_t Posted May 1, 2010 Author Share Posted May 1, 2010 Just the standard connection, it usually works. $con = mysql_connect("localhost", "test", "test" ) or die ('Sorry, could not connect at thie time.'); Link to comment https://forums.phpfreaks.com/topic/200343-error-message/#findComment-1051385 Share on other sites More sharing options...
trq Posted May 1, 2010 Share Posted May 1, 2010 $con is indeed not an object in your case. It is simply a connection resource. Link to comment https://forums.phpfreaks.com/topic/200343-error-message/#findComment-1051386 Share on other sites More sharing options...
dan_t Posted May 1, 2010 Author Share Posted May 1, 2010 Confusingly, that's what it says it is and where it is at...? line 30 30 if($con->error) { echo 'Something entered improperly: ' .$con->error; } it just doesn't make sense. Link to comment https://forums.phpfreaks.com/topic/200343-error-message/#findComment-1051389 Share on other sites More sharing options...
trq Posted May 1, 2010 Share Posted May 1, 2010 $con is NOT an object. You cannot try and get a property of something that isn't an object. You are trying to get the error property of $con, which doesn't have any properties. Try.... if (mysql_error($con)) { instead. Link to comment https://forums.phpfreaks.com/topic/200343-error-message/#findComment-1051390 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.