473,549 Members | 2,561 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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($li nk);
}
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 5750
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($li nk);
}
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**********@i nvalid.tryba.nl > wrote in
news:42******** *************** @news6.xs4all.n l:

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
1840
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 = mysql_connect("localhost", "root") or die ("Couldn't connect to the server."); $db2 = mysql_select_db("priceretail", $connection2) or die ("Couldn't select...
10
5098
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. Simplified, it'd be: $con1=mysql_connect($server, $user, $pass); mysql_select_db($database1, $con1); $res1=mysql_query($sql1, $con1); ...
2
2825
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 the table: <?php include("../config.php"); $dbi = mysql_connect($dbhost,$dbuname,$dbpass);
19
8091
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", ""); Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) in /var/www/html/buildhw.php on line 13
7
5404
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 using that username/passwd using mysql console), but when I change the db host into 127.0.0.1 mysql_connect will work. Beside of that I can't make my...
6
3354
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 was succesful, now I get: Can't connect to MySQL server on 'SERVER' (13)
1
4352
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 multiple SQL servers so that script tries to connect to resolved IPs until it finds one that works? I have set up DNS so that on request...
7
2839
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 using MySQL at the data layer. This is on a Windows XP machine, using IIS 6.0, MySQL 5.0, PHP 5. The problem I am having is that a call to...
2
2014
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 started from a web browser, one of the first things to happen is a call to mysql_connect which succeds without any problems. One component of...
0
7459
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7726
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7967
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5377
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5097
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3488
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1953
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
772
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.