Jump to content
MakeWebGames

Recommended Posts

Posted

Fatal error: Call to undefined function mysql_connect() in /home/modernma/public_html/includes/db_connect.php on line 11

 

<?php

$mysql_host = "localhost";

$mysql_user = "hidden";

$mysql_password = "hidden";

$mysql_database = "hidden";

$connection = mysql_connect("$mysql_host","$mysql_user","$mysql_password") or die ("Unable to connect to MySQL server.");

$db = mysql_select_db("$mysql_database") or die ("Unable to select requested database.");



?>
Posted
<?php
function_exists('mysql_connect') or die('mysql extension unavailable.');

$host = 'localhost';
$username = 'root';
$password = '';
$conn = mysql_connect($host, $username, $password);

assert(is_resource($conn));

The PHP documentation states that:

Use of this [mysql] extension is discouraged
So you should be looking for mysqli or PDO. Failing that, performing a basic requirements test (as can be seen above) in your code during startup is not a bad idea if you are on managed hosting as providers often fail to notify users of changes.
Posted
$connection = mysql_connect("$mysql_host","$mysql_user","$mysql_  password") or die ("Unable to connect to MySQL server.");

 

Why is there a space on $mysql_ password?

Posted
$connection = mysql_connect("$mysql_host","$mysql_user","$mysql_  password") or die ("Unable to connect to MySQL server.");

 

Why is there a space on $mysql_ password?

 

just the way it pasted here its not like that on my file manger

Posted
i get mysql extension unavailable.
You have your answer then. Move to a) a different MySQL extension - ie: mysqli or pdo (both of which if memory serve me usually use a native-to-PHP -itself extension so are immune to a degree from OS upgrades, or b) a different host. There is nothing wrong with the mysql extension per say; I've never had a single security problem with it over the more recent counter-parts even though that is one of the most often repeated (and incorrect) reasons for upgrading. Saying that, the mysql extension is rather old; there are a lot of features of MySQL that simply cannot be accessed from it - so it really is about time you upgraded. Check for the mysqli extension at the very least; it is almost a direct shoe-in with a little thinking.
Posted
You have your answer then. Move to a) a different MySQL extension - ie: mysqli or pdo (both of which if memory serve me usually use a native-to-PHP -itself extension so are immune to a degree from OS upgrades, or b) a different host. There is nothing wrong with the mysql extension per say; I've never had a single security problem with it over the more recent counter-parts even though that is one of the most often repeated (and incorrect) reasons for upgrading. Saying that, the mysql extension is rather old; there are a lot of features of MySQL that simply cannot be accessed from it - so it really is about time you upgraded. Check for the mysqli extension at the very least; it is almost a direct shoe-in with a little thinking.

ill give mysqli a go and keep you update thanks for the advice and your time

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...