stuartgpalmer Posted January 15, 2007 Share Posted January 15, 2007 My host recently upgraded me from MySQL 4.1 to 5. I have been using the mysql_connect command to connect from PHP but it has now been depreciated. Though there is online documentation for this command in mysql terms, I cannot find a PHP/MySQL solution.This is my code:<?php$user="my_username";$host="localhost";$password="my_password";$database ="my_database";$connection = mysql_connect($host,$user,$password) or die ("Couldn't connect to the database.");$db = mysql_select_db($database,$connection) or die ("Couldn't select database");?>Can anyone tell me how to turn this into a mysql_real_connect script which works with MySQL 5? I will post a jar of <a href="http://www.roystonpickles.co.uk">my finest chutney</a> to anyone who cracks this. Many thanks, I'm going spare. Link to comment https://forums.phpfreaks.com/topic/34304-mysql-5-php-mysql_connect/ Share on other sites More sharing options...
blear Posted January 15, 2007 Share Posted January 15, 2007 Your mysql_connect call appears functionally correct. What error message do you get, and are you sure PW and hostname are correct? Link to comment https://forums.phpfreaks.com/topic/34304-mysql-5-php-mysql_connect/#findComment-161428 Share on other sites More sharing options...
Zoud Posted January 15, 2007 Share Posted January 15, 2007 I don't know if this will help, but this is what I use to connect to mine:[code]<?php $con = mysql_connect("","","") or die('Error: <br />'. mysql_error());if (!$con) die("Error: ". mysql_error());mysql_select_db("database", $con) or die("Error: ".mysql_error());?>[/code] Link to comment https://forums.phpfreaks.com/topic/34304-mysql-5-php-mysql_connect/#findComment-161436 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.