The Paradigm

I recently was finally given a computer for work, which runs on Windows XP. I had previously been working using my personal Linux laptop, and had developed several MySQL/PHP applications to aid in data entry and SQL reporting, all of which ran on localhost. I use an "include" file to establish my connection, and run SQL inserts and updates via localhost. Ran like a champ in Linux.

The Problem

I installed WAMP Server (www.wampserver.com) on the new computer, and have now moved my data from the Linux laptop to the WinXP laptop. I actually did that pretty easily, but now, I find that I cannot connect using the username and password combinations. I tried to replicate them EXACTLY on the WinXP box, but no joy in Mudville, as they say.

The Parameters

Set up a very simple table:

id color employee
------------------------
1 Red Dan
2 Blue Mike
3 Yellow Cindy
4 Orange Gerri
5 Purple Rick
6 Green Crystal

Here's a copy of my "connection.php" file:

-----BEGIN PHP CODE-----

$db = mysql_connect("localhost", "testguy", "razreshayu");
if (!$db) {
echo "error!";
}
mysql_select_db("dangoof");

-----END PHP CODE-----

The test code to see if I can run a simple query:

-----BEGIN PHP CODE-----

include("connection.php");

$query = "select * from table1";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo "<p>".$row["id"]." - ".$row["color"]." - ".$row["employee"]."</p>";
}

-----END PHP CODE-----

I've run this code a thousand times without problems, but now, I get this error message:

-----BEGIN ERROR CODE-----
Warning: mysql_query() [function.mysql-query]: Access denied for user 'SYSTEM'@'localhost' (using password: NO) in C:\wamp\www\acs\dangoof\index.php on line 5

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\acs\dangoof\index.php on line 5

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\acs\dangoof\index.php on line 6
-----END ERROR CODE-----

I tried setting up a completely new user using PHPMyAdmin, and running it again - still no luck.

I also tested the MySQL connection in a command line, and it connects just fine. I also checked the "permissions," and removed the "read only" attribute in all the files in the wamp directory. The Windows Personal Firewall is OFF. The problem seems to be in the localhost, but I'm just not sure.

What am I missing? Are there some wacky settings in Windows XP I need to set to enable this functionality? Any insights would be greatly appreciated.

Dan sends...

In another forum, I read that "short" PHP opening and closiung tags are the problem. I had used the short tags:

-----BEGIN SHORT CODE-----
<?

?>
-----BEGIN SHORT CODE-----

I should have used LONG PHP tags:

-----BEGIN SHORT CODE-----
<?php

?>
-----BEGIN SHORT CODE-----

Now it works. Hope this helps somebody else!

Dan sends...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.