modernmafia Posted August 17, 2012 Posted August 17, 2012 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."); ?> Quote
modernmafia Posted August 17, 2012 Author Posted August 17, 2012 was literally working half ago on that now throws the error Quote
Octarine Posted August 17, 2012 Posted August 17, 2012 <?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 discouragedSo 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. Quote
modernmafia Posted August 17, 2012 Author Posted August 17, 2012 i get mysql extension unavailable. Quote
Razor42 Posted August 17, 2012 Posted August 17, 2012 $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? Quote
modernmafia Posted August 17, 2012 Author Posted August 17, 2012 $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 Quote
modernmafia Posted August 17, 2012 Author Posted August 17, 2012 Make sure as that would return an error. check and there no spaces ? Quote
Octarine Posted August 17, 2012 Posted August 17, 2012 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. Quote
modernmafia Posted August 17, 2012 Author Posted August 17, 2012 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 Quote
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.