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($sq l);
echo "<table border='1'>
<tr>
<th>levelname </th>
<th>mingamespla yed</th>
<th>mingameswon </th>
</tr>";
while($row = mysql_fetch_arr ay($result))
{
echo "<tr>";
echo "<td>" . $row['levelname'] . "</td>";
echo "<td>" . $row['mingamesplayed '] . "</td>";
echo "<td>" . $row['mingameswon'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($db Conn);
?>[/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
7 2840 dlite922 1,584
Recognized Expert Top Contributor
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.
Nope, nada, zilch, nothing....
I have the php.ini entries set up for error logging and nothing gets logged.
What else should I check?
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($sq l);
if(!$result){ die mysql_error(); }
echo "
<table border='1'>
<tr>
<th>levelname </th>
<th>mingamespla yed</th>
<th>mingameswon </th>
</tr>";
while($row = mysql_fetch_arr ay($result))
{
echo "<tr>";
echo "<td>" . $row['levelname'] . "</td>";
echo "<td>" . $row['mingamesplayed '] . "</td>";
echo "<td>" . $row['mingameswon'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($db Conn);
?>
[/PHP]
TheServant 1,168
Recognized Expert Top Contributor
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", "thepasswor d") 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("SE LECT * 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!
or you could just try the one i posted :P it has to work :D lol
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!
Markus 6,050
Recognized Expert Expert
or you could just try the one i posted :P it has to work :D lol
More than one suggestions are welcome.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 test php script to test mysql (ftp_connect('localhost',
'root');), but got the following error:
Warning: mysql_connect(): Can't connect to local...
|
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);
|
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
|
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...
| |
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 function mysql_connect() in E:\www
\mysite\connecttest.php on line 2
|
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 passwords.
Then I use that information to connect to the database. So every user
have his own database.
|
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 in my php script, it simply
stops executing. In other words anything or'ed with it, like echo
does not end up in the html source. I'm not entirely...
|
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...
|
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...
| |
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. ...
|
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...
|
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...
|
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...
|
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...
| |