dongzi1397 2015-08-29 15:28
浏览 102

Dreamweaver和MYSQL的ConnectionString

I'm trying to create a connection string in dreamweaver with MySQL. It is my first tutorial with php and MySQL so excuse me if I'm missing something. This is my connectionString code:

  <?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_explorecalifornia= "mysql:host=localhost;
dbname=explorecalifornia;charset=utf8";
$database_explorecalifornia = "explorecalifornia";
$username_explorecalifornia = "root";
$password_explorecalifornia = "";
$explorecalifornia = mysql_pconnect($hostname_explorecalifornia,
$username_explorecalifornia, $password_explorecalifornia) or trigger_error
(mysql_error(),E_USER_ERROR); 
?>

I'm getting this error :

Deprecated: mysql_pconnect(): The mysql extension is deprecated and will
be removed in the future: use mysqli or PDO instead in
C:\wamp\www\dwwithphp\Connections\explorecalifornia.php on line 9

I tried using mysql_connect(),mysqli() and PDO() but I also have an error:

    Warning: mysqli::mysqli(): php_network_getaddresses: getaddrinfo
 failed: No such host is known. in
 C:\wamp\www\dwwithphp\Connections\explorecalifornia.php on line 9

similar error for the other methods. the last two days I've been searching for a solution with no luck. I'M using :Apache/2.4.9 (Win64) PHP/5.5.12,MySQL 5.6.17 and Dreamweaver cs5

Edit
I tried uninstalling wamp server and reinstalling it but it didn't work I've got the same errors. I don't know what to do next, i really need help.

  • 写回答

2条回答 默认 最新

  • douyi3760 2015-08-29 16:48
    关注

    The mysql php APIs deal with constructing the connection string mysql:host=hostname stuff internally.

    Friends don't help friends connect with the old, nasty, deprecated, insecure mysql_ api.

    To connect with mysqli, you want something like this:

    $hostname = "localhost";  
    $database = "explorecalifornia";
    $username = "CONCEALED";
    $password = "CONCEALED";
    
    $conn = new mysqli($hostname, $username, $password, $database);
    if ($conn ->connect_error) {
    die('Connect Error (' . $conn ->connect_errno . ') '
            . $conn ->connect_error);
    
    $conn->set_charset('utf8') || die "cannot set character set.";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题