Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
| Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 9th, 2004, 08:11 AM
Authorized User
Join Date: Apr 2004
Location: , , Ireland.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default database connection

Can anyone help
have just started to learn php and mySQL so am totally new to it all together and am trying to connect to the server with no luck keep getting this error "Fatal error: Call to undefined function mysql_connect() in C:\phpTestsite\index.php on line 6
" cant figure out what i'm doing wrong .
here is the code im using.
$hostname = "";
$username = "root";
$password = "secret";
$connection = mysql_connect($hostname, $username, $password);
if (!$connection) {
die("A connection to the server could not be established");
} else {
echo "User $username is logged onto the MySQL server, $hostname, successfully";

any help appreciated

ps using win xp pro and testing on iis 5 .other php pages work fine but its when i try to connect to the something i get the error.:(

Old November 9th, 2004, 09:12 AM
Registered User
Join Date: Sep 2004
Location: Javea, Alicante, Spain.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts

$hostname = "localhost";

Old November 9th, 2004, 05:29 PM
Authorized User
Join Date: Jul 2004
Location: rajshahi, , Bangladesh.
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rajuru Send a message via Yahoo to rajuru

i think you are using PHP5
in PHP5 mysql support is not installed by default.

you have to install it.

go through www.php.net to know how to activate mysql in PHP5 or you can use PHP 4.3.8

Best Regard:
Md. Zakir Hossain (Raju)
Old November 10th, 2004, 05:05 AM
Authorized User
Join Date: Apr 2004
Location: , , Ireland.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts

thanks for that ! very confusing i though i did not install my sql properly but am able to create databases etc. so it can't be that .
i give it a try thanks for the tip;)

Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Connection to Access Database reachsevar ASP.NET 2.0 Basics 1 November 28th, 2007 08:56 AM
Database Connection oneillg PHP Databases 1 October 17th, 2007 04:48 PM
Database Connection kapi.goel SQL Language 2 February 14th, 2006 07:01 PM
database connection Nitin_sharma Classic ASP Databases 1 February 8th, 2005 10:23 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.