Jump to content

Php file connected to MySQL?


eduard
 Share

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! Edited by eduardchile
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...