Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Can't get mysql to work with php


  • Please log in to reply

#1
m2zt

m2zt

    Member

  • Member
  • PipPip
  • 75 posts
i am using mysql-4.0.18, apache_1.3.33 and php5

i try this code
<html>

<head>
<title>MySQL Connection Test</title>
</head>

<body>
<h2>
<?php $connection = mysql_connect( "localhost", "root", "" )
or die( "Sorry - unable to connect to MySQL" );
echo( "Congratulations - you connected to MySQL" );
?>
</h2>
</body>

</html>

and i get an error
Fatal error: Call to undefined function mysql_connect() in c:\Apache\htdocs\mysqltest.php on line 11
  • 0

Advertisements


#2
ssone

ssone

    Member

  • Member
  • PipPipPip
  • 301 posts
Are you putting your provided names in the spots: "localhost" "root" and "".

In other words, those are "localhost" "user" and "user_pw"

Here's a less confusing one:
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

  • 0

#3
m2zt

m2zt

    Member

  • Topic Starter
  • Member
  • PipPip
  • 75 posts
thanks ssone

that helped alot!
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP