[web] PHP Problem

Recommended Posts

dave    2187
Hey, Write so i have started coding. Now what i am trying to do is simply connect to the sql server that i have on my own computer. So i tried this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<body>
<?php
$msqlDbLink = msql_connect( "DAVESCOMPUTER" ); //$sql = 'CREATE DATABASE s DEFAULT CHARACTER SET ascii COLLATE ascii_general_ci';
echo "hello1!";

if ( $msqlDbLink != FALSE ) { echo "hello2!"; msql_close($msqlDbLink );
}

?>
</body>
</html>


Now the handle that is return is FALSE. Any ideas what the host address is supposed to look like, i have also tried 'localhost'. Thanks in advance. Dave

Share on other sites
chollida1    532
Here's how I call the method

$con = msql_connect(); msql_select_db("test_db",$con);

Cheers
Chris

dave    2187

Dave

Share on other sites
ToohrVyk    1595
The default server (used when you do not supply arguments) is 'localhost:3306'

Share on other sites
TheGangster    134
Well in order to do what you want to you will need to connect to the server, and after that you will need to select a database.
You will need to use the function @mysql_connect which takes 3 parameters.

@mysql_connect( $hostip,$dbusername, $dbpassword ); That$hostip is your ip, if you are using it localy you will need to set it to hostname or 127.0.0.1 .

The $dbusername is your database username, the one you set on your mysql server, and$dbpassword is your database password, the same that you set on your mysql server (on install usualy).

After this you might want to make sure you connect to the server by doing:
$sqlconnect = @mysql_connect($hostip, $dbusername,$dbpassword );if ( !$sqlconnect ){ die( mysql_error() );} Hope this help. :) Share this post Link to post Share on other sites Guest Anonymous Poster Is MSQL the same as MySQL? Share this post Link to post Share on other sites dave 2187 When i installed mysql with xampp i never set up a username and password, i was never prompted to. All attempts to connect have failed thus far. Dave Share this post Link to post Share on other sites TheGangster 134 No sorry, read it wrong but still it is almost the same thing. MS SQL Server means Microsoft SQL Server and is microsoft's, and MySQL is a free open source one. Instead of: $sqlconnect = @mysql_connect( $hostip,$dbusername, $dbpassword );if ( !$sqlconnect ){	die( mysql_error() );}

You will need to to:
$sqlconnect = mssql_connect($hostip, $dbusername,$dbpassword );

YAY!!

Share on other sites
TheGangster    134
And don't forget that MsSQL is not the same as MySQL :). And for a manual about PHP you can check it's manual at http://www.php.net/docs.php.

dave    2187
rate++