473,769 Members | 5,072 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_m ysql.dll

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

<?php

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

$conn=@mysql_co nnect( "localhost" , "root", "admin" );
echo("<br>Conne cted to the database!");

$rs = @mysql_select_d b( "crowdwisdo m", $conn );
---------------------------------------------------

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

Help?
Dec 5 '05 #1
3 1593
Martin wrote:
No errors are generated. $conn=@mysql_co nnect( "localhost" , "root", "admin" );
echo("<br>Conne cted 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_con nect( "localhost" , "root", "admin" );
if( !$conn )
die( "<br>Databa se connection failed!" );

echo("<br>Conne cted to the database!");
Dec 5 '05 #2
On Mon, 05 Dec 2005 20:48:28 +0000, Aggro wrote:
No errors are generated.
$conn=@mysql_co nnect( "localhost" , "root", "admin" );
echo("<br>Conne cted 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
1544
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 queries are identical except for two variables. I have checked my form and they are correct and are being sent to the PHP script the way they should be. The variables are $playerto, $playerfrom, $nameto, $namefrom. The 'TO' query is the one that...
3
1851
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 following makefile: all: SCM exampleSQL
1
1972
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 many tables with hundreds of fields). I can run the script in the mysql interface but I want to do this from my access front end to make it easy for the user to set up the tables. I need something like myconnection.execute...
5
5335
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 it whatsoever (I connect to it from Tomcat and from stand-alone Java classes), now since I installed XAMPP I cannot connect to it at all, cannot start service... I uninstalled XAMPP completely, and my MySQL server still doesn't work.. so why...
3
2605
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 script (this is used to identify the torrent). If we have the collation as latin1_general_ci, and I don't send any SET NAMES OR SET CHARACTER SET queries after connecting, my announce script can successfully retrieve the row from the torrents...
1
1730
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 database and run a "select * from <table>" query. The language is below, taken essentially from the docs. the language does, well, nothing. it neither throws an error nor echo's "Worked."
1
1216
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 script and it worked. Then...I tried to update it from dotdeb, and problems started. The script doesn't work and mysql-admin says my client is 4.1 while apt-get says I have 5.0. The test script also still works as mysql 4. Also: I can use the gui...
15
2961
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, controlled via Plesk control panel, and turned over to me with Fedora Core 6 in an empty state. This is the standard way you get a server in a colo today. Bringing Python up in this completely clean environment is a huge hassle, and it doesn't...
2
2266
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 configuration has IIS on one server, and MySQL on another, both machines are approximately equivalent to the old (aka current) box power wise.. The problem I am having is that a given script (granting it is based on an ugly query with 7 joins) runs in a...
0
9423
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,...
0
10048
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9996
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
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...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3963
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

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.