Hi all. I've recently set up Apache 2.2 with PHP 5.2 and MySQL 5.1. I played around with SQL a bit, and now I'm trying to access it with PHP. I currently have the code: - <?php
-
-
# error_reporting(E_ALL);
-
# ini_set('display_errors', true);
-
-
echo "test";
-
-
$link = mysql_connect('localhost', 'root', '[mypassword]');
-
if (!$link) {
-
die('Could not connect: ' . mysql_error());
-
}
-
echo 'Connected successfully';
-
-
?>
-
When I run the above in Firefox with my correct password, all I get is "test", verifying to myself that PHP was working when the script ran. I've also verified that the username and password correctly start MySQL though the CLI, but I don't think that's the issue here. If they were incorrect, I should get the "Could not connect" message and the MySQL error, but I get no errors at all. This makes me think the mysql_connect function itself isn't working right.
What possible mistakes could I be making? Thanks in advance.
May 28 '09
12 4928 @Atli
I think that was just an extraordinarily unlikely typo. I had heard of both mysql and mysqli, and I knew I was looking for mysql. Or maybe I just copied and pasted it from somewhere without noticing the 'i'.
Thanks for the tips, I'm sure they would have worked, but after changing so many settings over the past few days, I figured that even if I had fixed the problem, one of my other changes would have messed it up and I wouldn't know that I had fixed it. An hour ago, I uninstalled everything in order to start over and then saw Markus' comment. I've now got easyPHP installed and all my earlier problems are fixed. Now I just wish that I had saved my site and database before I deleted the Apache and MySQL folders. *facepalm*
Thanks all for your help, much appreciated.
Markus 6,050
Recognized Expert Expert @Hendor
Yeah, I've been there before. You change so much in blind hope that it'll fix something. And then, when you do fix the error, you've caused other errors, and then you decide to walk away from the computer before beating it. @Hendor
Been there too. I've lost lots of stuff doing that; thankfully, it wasn't important stuff.
Mark.
Atli 5,058
Recognized Expert Expert @Hendor
I did the same thing yesterday :)
Lost and entire MSSQL database I spent the last 2 days building.
Anyways, I'm glad you've got your sever working now.
P.S.
You should try using Linux as a server someday.
On my Ubuntu test server this entire problem would have been solved by a single command: - $sudo apt-get install php5-mysql
Easy, right? :P
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 database.");
$sql2 = "SELECT dbname FROM productlist WHERE ((accountid =
'printingautomation') OR...
|
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);
$con2=mysql_connect($server, $user, $pass);
|
by: awdsites |
last post by:
Hi,
I'm a noob with a server so keep that in mind :) Been trying to connect
with php to mysql and all I get is:
"Fatal error: Call to undefined function: mysql_connect()"
I've read and read and can't figure out what is wrong. My current set
up is:
|
by: ezmiller |
last post by:
Hi,
I am very new to php, and I am trying to use it to access a mysql
database. But I'm trying to use mysql_connect but the browser returns
the following error sayin that the mysql_connect function is undefined.
Why? Can anyone help?
Fatal error: Call to undefined function mysql_connect() in
C:\Data\Now\ContractWork\FriendsKnitting\LiveWebSite\friends_emailsubmit.php
on line 11
|
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 php script to do I/O operation on
dir/file in the apache /var/www though the permision already own...
| |
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)
|
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 sql.example.com it returns two
|
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 mysql_connect is not working, it is not doing anything at all. I'm not getting any error messages, or...
|
by: Kjell Pettersen |
last post by:
Hello!
I have installed PHP and MySql 5.0 on Win XP.
Database created ok. Installation ok.
PHP scripts runs ok.
But when I am trying some mysql calls in the script I get an "Error 500"
from explorer.
// Connect to the database server
echo ('Trying to connect to db');
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |