473,386 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

mysql_connect()

Hello,

I am having trouble connecting to my server with mysql_connect(). I can
connect via the command line on the server and with phpMyAdmin over our
network, but not though mysql_connect(). This is my script:

<?php
$host = '192.168.100.5';
$user = 'root';
$pass = <password>;

echo '<P>Connecting...</P>';
//echo 'mysql_connect('.$host.', '.$user.', '.$pass.');';
//$link = false;
$link = mysql_connect($host, $user, $pass) or die(mysql_error());

if ($link)
{
echo '<P>Connection OK!</P>';
mysql_close($link);
}
else
{
echo '<P>Connection failed.</P>';
}
?>
The last thing I see on the page when I load this is "Connecting..." -
nothing else. It's been a while since I have worked with PHP/MySQL so
please bear with me!

Thanks,
Andrew
Jul 17 '05 #1
4 5735
Andrew Clark wrote:
Hello,

I am having trouble connecting to my server with mysql_connect(). I can
connect via the command line on the server and with phpMyAdmin over our
network, but not though mysql_connect(). This is my script:

<?php
$host = '192.168.100.5';
$user = 'root';
$pass = <password>;

echo '<P>Connecting...</P>';
//echo 'mysql_connect('.$host.', '.$user.', '.$pass.');';
//$link = false;
$link = mysql_connect($host, $user, $pass) or die(mysql_error());

if ($link)
{
echo '<P>Connection OK!</P>';
mysql_close($link);
}
else
{
echo '<P>Connection failed.</P>';
}
?>
The last thing I see on the page when I load this is "Connecting..." -
nothing else. It's been a while since I have worked with PHP/MySQL so
please bear with me!


Call echo mysql_error(); after every MySQL function call to find out
what the issue is.

--
Oli

Jul 17 '05 #2
Andrew Clark <no****@nospam.com> wrote:
I am having trouble connecting to my server with mysql_connect(). I can
connect via the command line on the server and with phpMyAdmin over our
network, but not though mysql_connect(). This is my script:


Both these methods connect to "localhost". Your script suggests remote
access, this will not work since in many cases networking is disabled by
default (Good Thing(tm)). So read the mysql documentation and make sure
it's accepting remote network connections.

Jul 17 '05 #3
Daniel Tryba <pa**********@invalid.tryba.nl> wrote in
news:42***********************@news6.xs4all.nl:

Both these methods connect to "localhost". Your script suggests remote
access, this will not work since in many cases networking is disabled
by default (Good Thing(tm)). So read the mysql documentation and make
sure it's accepting remote network connections.


Well, since I am running this on my local machine, I changed it to
locahost anyway. That IP was my machine's IP. But anyway.

After I changed it to localhost it still is not connecting. Nothing is
being output to the page after the call to mysql_connect().

Andrew
Jul 17 '05 #4
I got it! Wow, not too smart, I am.

It seems I kind of forgot to enable the MySQL extension in php.ini...

Thanks to all,
Andrew
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: LRW | last post by:
I'm working on some scripts someone else made, and it's littered with repetitive mysql_connect's and mysql_select_db's. For example: // MAKE SURE IT IS A VALID PRODUCT $connection2 =...
10
by: Alvaro G Vicario | last post by:
I need that my script retrieves data from two different databases so I use mysql_connect() to open two connections. I have only one server, user and password, just two different databases....
2
by: Sugapablo | last post by:
I have a small test script connecting to a MySQL database. It seems to work, unless I try to use the resource link identifier returned by mysql_connect(); This works and returns all the rows in...
19
by: Michael | last post by:
Hi, I'm trying to do something which should be very simple - connect to the MySQL database. Here is the call, followed by the error msg. $conn = mysql_connect("localhost", "root", ""); ...
7
by: avenpace | last post by:
Hi, I got error when using mysql_connect function in my php script. If i set the db host to localhost, it give me that error altough all the user and password that I wrote is true(I can login...
6
by: GD | last post by:
Hi All, I've got MySQL 5.0.21 running on Windows Server 2003, and php running on Apache on a Linux box (Fedora Core 4). Previously when the pages were running on an IIS server the connection...
1
by: hugo | last post by:
Hello people, There is a problem is that mysql_connect() somehow caches last sessions IP and is not using the one which you put into host place. Has anyone made mysql_connect() from php to...
7
by: criveraf | last post by:
Hi there, I wasn't sure where to put this question, since it deals with both PHP and MySQL. I apologize if this is not the correct forum for this. I am working with a simple PHP application...
2
by: Ralf Seliger | last post by:
Hi, I hope someone here has a clue as to what is going on since I am completely baffled by the following: I'm working with a PHP/MySQL-web application called Moodle. When this application is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.