Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
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