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

mysql_connect not doing anything at all

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 warnings, or a whistle, or whatever. It just does nothing at all.

This is the script:

[PHP]<?php

$dbConn = mysql_connect('127.0.0.1', 'root', 'thepassword') or die('Could not connect: ' . mysql_error());

echo "HURRAY! mysql_connect works!<br>"; // this line never gets displayed on the page

if (!$dbConn)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("mydb", $dbConn);

$sql="SELECT * FROM levels";

$result = mysql_query($sql);

echo "<table border='1'>
<tr>
<th>levelname</th>
<th>mingamesplayed</th>
<th>mingameswon</th>
</tr>";

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['levelname'] . "</td>";
echo "<td>" . $row['mingamesplayed'] . "</td>";
echo "<td>" . $row['mingameswon'] . "</td>";
echo "</tr>";
}
echo "</table>";

mysql_close($dbConn);
?>[/PHP]

I put the line that says [PHP]echo "HURRAY! mysql_connect works!<br>";[/PHP] as a reachmark; however, it never gets displayed, and I am not getting the data requested. All I get is a blank page. I even put a wrong host, username and password to provoke an error, and I don't EVEN get an error.

MySQL is working. I have created, populated and retrieved data using the tools provided by MySQL. I have created other PHP pages --not using MySQL calls-- and they work just fine.

I have tried whatever I have read throughout the internet with not success. I have checked the php.ini file for the extensions and extensions_dir, and the place where the libmysql.dll and the php_mysqli.dll should be, etc, etc, etc. But I get nothing, nothing at all.

I think here's all the info, but if you need something else to help me out, let me know to give you that extra info. You can ask me anything, even if I have tried it, so just in case whatever I have tried I have done it incorrectly.

Please help, and thanks in advance.

C
Feb 20 '08 #1
7 2822
dlite922
1,584 Expert 1GB
Do you have error reporting sign.

When you get a blank page, that's usually a telltale sign that a fatal error has occured and error reporting is not on.

Check your php.ini file to turn these on, test it by a new PHP file and try to make an error. forget a { or a semicolon. It should warn you.
Feb 20 '08 #2
Nope, nada, zilch, nothing....

I have the php.ini entries set up for error logging and nothing gets logged.

What else should I check?
Feb 21 '08 #3
Hey!

Try This:


[PHP]
<?php

$dbConn = mysql_pconnect('127.0.0.1', 'root', 'thepassword');
if (!$dbConn){ die('Could not connect: ' . mysql_error()); }

echo "HURRAY! mysql_pconnect works!<br>"; // this line should be displayed now

mysql_select_db("mydb", $dbConn);

$sql="SELECT * FROM levels";

$result = mysql_query($sql);
if(!$result){ die mysql_error(); }

echo "
<table border='1'>
<tr>
<th>levelname</th>
<th>mingamesplayed</th>
<th>mingameswon</th>
</tr>";

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['levelname'] . "</td>";
echo "<td>" . $row['mingamesplayed'] . "</td>";
echo "<td>" . $row['mingameswon'] . "</td>";
echo "</tr>";
}
echo "</table>";

mysql_close($dbConn);
?>
[/PHP]
Feb 21 '08 #4
TheServant
1,168 Expert 1GB
Instead of:
<?php

$dbConn = mysql_connect('127.0.0.1', 'root', 'thepassword') or die('Could not connect: ' . mysql_error());

echo "HURRAY! mysql_connect works!<br>"; // this line never gets displayed on the page

if (!$dbConn)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("mydb", $dbConn);

$sql="SELECT * FROM levels";

..
Try:
[PHP]
mysql_connect("127.0.0.1", "root", "thepassword") or die('Could not connect to MySQL: ' . mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("mydb") or die('Could not connect to Database: ' . mysql_error());
echo "Connected to Database";

$result = mysql_query("SELECT * FROM levels") or die('Could not connect to Table: ' . mysql_error());

[/PHP]

You were dying twice for some reason (line 3 and 9 or your code) and even though it might work, I am not familiar with the way you wrote it with regards to how you use mysql_select_db and a few others. Then again, I am very new, so maybe everything I have said is a waste of time. If so, let me know and I will shut up!
Feb 21 '08 #5
or you could just try the one i posted :P it has to work :D lol
Feb 21 '08 #6
Many thanks to all who replied.

All suggestions are good, but they are all the same. In fact, my lines of code were taken from a working example.

Anyway, I am embarassed to say that it now works and it only required a good old reboot of my machine!! :S

Although one thing that hint me about doing a reboot was the php.exe shell. I invoked my php page through the shell and it gave me the error messages that were not showing up on the browser. So I corrected them and rebooted.

TA-DA!

I leave this information for everyone, so nobody else goes through this embarassment... :-(

Again, thanks to all who posted!
Feb 21 '08 #7
Markus
6,050 Expert 4TB
or you could just try the one i posted :P it has to work :D lol
More than one suggestions are welcome.
Feb 21 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Neo | last post by:
It's really strange. I downloaded the latest 4.0.16 RPM from mysql.com and installed it to my Fedora system, and did *not* do anything else (Actually I am completely new to mysql). I wrote a...
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", ""); ...
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...
14
by: brett | last post by:
I'm running PHP5 on Windows Vista with mysql 5.2. I have a simple php file with <? $dbc = mysql_connect (); ?> When I run the file, I get this error: Fatal error: Call to undefined...
5
by: Shmuel | last post by:
Hello, Is it possible to give to mysql_connect an encrypted (md5 or sha1) password? If not is there a workaround? I store passwords for users in database and don't want to use plain text...
14
by: farhan | last post by:
Hi, Please divert me if this is not the right group to be posting this question. I am a Linux client trying to connect to a mysql windows server via php, upon hitting the mysql_connect line...
8
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.