473,395 Members | 1,497 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,395 software developers and data experts.

Problems trying to get MySQL to work from PHP script

I'm having trouble getting a new PHP/MySQl installation to work.

Windows XP Pro, IIS 5.1, PHP 5.1.1, MySQL 5.0.16, ISAPI

This is a new computer. The whole setup is for development use only -
no access from beyond my own network.

PHP seems to be working OK. I can open a test.php page ok - It
executes down to the statement where I try to connect to the MySQL
database. At that point, nothing further happens. The page is served
out. No errors are generated.

MySQL also seems to be working. I've installed MySQL Administrator
and, from what I can see, everything looks OK. I have a database - it
has tables in it - the tables have data in them - I can execute
queries against them. This database is a copy of one I developed on
another machine

FWIW, the MySQL extension is activated in the PHP.INI file thus:
extension=php_mysql.dll

Here's the beginning of the script in the test.php page:
--------------------------------------------------
Here we go!

<?php

echo("<br>Inside the php script!");

$conn=@mysql_connect( "localhost", "root", "admin" );
echo("<br>Connected to the database!");

$rs = @mysql_select_db( "crowdwisdom", $conn );
---------------------------------------------------

When this runs, the displayed page consists of:
Here we go!
Inside the php script!

Help?
Dec 5 '05 #1
3 1578
Martin wrote:
No errors are generated. $conn=@mysql_connect( "localhost", "root", "admin" );
echo("<br>Connected to the database!");


Your problem is that you don't know php. If mysql_connect() fails, your
program won't print any errors and it won't stop there. The @-characters
in front of a function disables printing of any internal error messages
and since you don't even thech the result of $conn, you won't get any
information if the function fails or doesn't fail.

Solution:

$conn=mysql_connect( "localhost", "root", "admin" );
if( !$conn )
die( "<br>Database connection failed!" );

echo("<br>Connected to the database!");
Dec 5 '05 #2
On Mon, 05 Dec 2005 20:48:28 +0000, Aggro wrote:
No errors are generated.
$conn=@mysql_connect( "localhost", "root", "admin" );
echo("<br>Connected to the database!");


Your problem is that you don't know php.


Inflamatory considering that you seem to have misunderstood his point...
If mysql_connect() fails, your
program won't print any errors and it won't stop there. The @-characters
in front of a function disables printing of any internal error messages
and since you don't even thech the result of $conn, you won't get any
information if the function fails or doesn't fail.


I think you're missing the OPs point. The code (better formatted as you
typed it above) should try to connect to the database (without printing
errors or stopping). Then it should print a line of text (regardless of
connection or not).

The OP is saying it never gets that far! It only prints the first line,
which means the script is stopping on the mysql_connect line, not just
failing to connect.

To be honest, I'd say that for some reason it's not recognising the MySQL
extension and if you remove the @ symbol you'll get a fatal error saying:

"undefined function mysql_connect"

The script is therefore stopping at that point but your @ is supressing
the printing of the message.

But that's just a best guess, I've never had PHP not recognise the MySQL
extension, but then again I've never installed it on Windows...

Cheers,
Andy

--
Andy Jeffries | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

Dec 7 '05 #3
Andy Jeffries wrote:
I think you're missing the OPs point. The code (better formatted as you
typed it above) should try to connect to the database (without printing
errors or stopping). Then it should print a line of text (regardless of
connection or not).


I don't think I missed the point, but I admit that I didn't read the
whole message very carefully. The reason for that is that I wouldn't
bother solving the real problem before I had fixed the first problem.
And the first problem was that no error messages were printed out while
there surely were errors.

But thank you for making this clear.
Dec 7 '05 #4

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

Similar topics

0
by: C. Reeve | last post by:
Hi, Not sure if the problem here is PHP or MySQL, but here we go. I am trying to do two queries on a database - one after the other, but the second one never seems to get executed. The two...
3
by: Griff | last post by:
Hi there I'm trying to run some CGI programs under Apache, written in C++, which use the "libmysqlclient" MySQL library. This is all running on Solaris. I build my programs using the...
1
by: Paradigm | last post by:
Does anyone know how I can use vba in access to run a script that is stored as a file. I can make a connection to mysql database and run sql statements but this sql statement is very long (creates...
5
by: Frances | last post by:
a few days ago I installed XAMPP in my Windows 2000 machine, it completely messed my existing MySQL installation.. I've had it installed for over a year now (4.1) have never had any problems with...
3
by: Joshua Morgan | last post by:
Hey, Currently me and a friend are coding up a new BitTorrent tracker. We have a torrents table that has a column called 'info_hash' which contains the info_hash as received by the announce.php...
1
by: Swincher | last post by:
Hey - - -- --- --- - -- - Any data folks out there? I have started investigating the use of MDB2 for a data object. So far, it is winning the struggle... I am just trying to connect to a...
1
by: tannenba | last post by:
Ok- I'm a dummy. I got this book "php and mysql for dummies" and decided to learn it from the book. I loaded my sarge originally with mysql 4 and php4 from the debian pkgs. I tried the test...
15
by: John Nagle | last post by:
I've been installing Python and its supporting packages on a dedicated server with Fedora Core 6 for about a day now. This is a standard dedicated rackmount server in a colocation facility,...
2
by: Adam McCormack | last post by:
Good morning! I am on a project where we are migrating a site running on perl and mysql on IIS. The current configuration is with everything on one server, both IIS and MySQL. The new...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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,...
0
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...

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.