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) Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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.'); Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.