开发者

Making a local connection between a mysql database and php

开发者 https://www.devze.com 2022-12-21 01:33 出处:网络
I already have the mysql database made, I just need to connect php to mysql locally but I don\'t 开发者_Python百科know the php commands for that.

I already have the mysql database made, I just need to connect php to mysql locally but I don't 开发者_Python百科know the php commands for that.

cheers


$server = 'localhost';
$user = 'myUser';
$pass = 'myPass';
$dbname = 'MyDatabase';
$con = mysql_connect($server, $user, $pass) or die("Can't connect");
mysql_select_db($dbname);


The following contains a pretty good example: http://ca3.php.net/manual/en/mysql.examples-basic.php


This is a simple connect to the mysql server. After Connecting to the server it selects a DB

<?php
mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("test") or die(mysql_error());
echo "Connected to Database";
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消