Jump to content

Php file connected to MySQL?


eduard

Recommended Posts

See examples in the tutorial. As the paragraph above the first example says, if the connection fails, the "die" part will execute. Logically, if it's NOT executed, you can assume PHP is connected to MySQL.

Link to comment
Share on other sites

See examples in the tutorial. As the paragraph above the first example says, if the connection fails, the "die" part will execute. Logically, if it's NOT executed, you can assume PHP is connected to MySQL.
Thanks, however I don´t like the verb: ´assume´! I want to be sure!
Link to comment
Share on other sites

Let me paraphrase that... you can SAFELY assume PHP is connected to MySQL... if you don't see the error message.mysql_connect() can return only two things - the boolean value false (in which case the connection failed) and a MySQL resource (in which the connection was successful).The examples on W3Schools test if the value is false, and if it is, they show the error message. Because the only other option is known to be a MySQL resource, it is SAFE to assume that if the value is not false, the connection is successful.The assumption would not be safe if there was a third thing that mysql_connect() could return, but in this case, there isn't.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...