Question

Disclaimer

While I know the mysql_[command] functions are depreciated, this is for a school project and I started before they became depreciated. I don't get marked on the "up-to-date-ness" of the functions used, only the complex-nature of the program I have written therefore there was no incentive to change to PDO or mysqli. I have to include a variable-listing of all the variables I have used (including data type...) even though they aren't defined in the same way as vb.net for example.

The big question I have!

What is the data type of the variable $link in the code listed below? Where a data type is for example a string, integer, boolean value, etc...

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
Was it helpful?

Solution

If it connects successfully it'll be a resource identifier, otherwise a boolean:

Returns a MySQL link identifier on success or FALSE on failure.

See: http://php.net/manual/en/function.mysql-connect.php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top