How to connect PHPmyadmin to Flash CS4 using localhost

I am using wampserver, to run phpMyadmin. Phpmyadmin is working fine, and i have created the website without any problem. But i have run into a problem. Im basically following the tutorial below:

http://library.creativecow.net/articles/brimelow_lee/php_mysql/video-tutorial.php

My aim is to create a PHP file that will link with Flash CS4. But when testing the PHP file in a browser, which is an instruction of the tutorial, the database does not dispaly.

Two reasons why I think it may not work, I am a bit new to this, so am unsure if this is correct;

I am running it of local host  to connect the php file to a flash file using localhost is not possible???

The PHP coding is incorrect? although I have followed exactly what the tutorial said. NOTE: I have not used a password on the database on phpmyadmin, I tried to set it up a few times by going to privileges but this does not seem to work.

The code has been provided.

Kindly advise.
<?PHP

$link = mysql_connect("localhost","root");
mysql_select_db("qof_codes");

$query = 'SELECT * FROM disease_type';
$results = mysql_query($query);

echo "<?xml version=\"1.0\"?>\n";
echo "<disease_type>\n";

while($line = mysql_fetch_assoc($results)) {
        echo "<item>" . $line["product"] . "</item>\n";
        }
        
echo "</products>\n";
        
mysql_close($link);

?>

Open in new window

SherryRzvAsked:
Who is Participating?
 
psimationConnect With a Mentor Commented:
HI

I think you miss-understood.

The first line :

$link = mysql_connect("localhost","root", "??password??");
 
What I'm syaing is - you usually need a password as well to connect to MySQL ( any DB for that matter in any language)

So, substitute ??password?? with whatever the "root" password is for your mysql.

Then, the two lines I indicated with <<<<<<< This was to point out potential other problems that may pop-up.

You are trying to output your results as XML, for that you need matching opening and closing nested nodes.

On line 10 you open the root node as <disease_type>, but on line 16 you close it as </products>, I think line 16 should also be </disease_types> ?

Also, try to change line1 as follow ( AFTER you put in your mysql root password"

$link = mysql_connect("localhost","root", "your_root_password_here") or die ("Cannot connect");

If you see "Cannot connect" when you try to load your page, then there is something wrong with your mysql connection or the credentials you are using.


0
 
psimationCommented:
1. $link = mysql_connect("localhost","root", "??password??");

2. echo "<disease_type>\n"; <<<<< <disease_type>

while($line = mysql_fetch_assoc($results)) {
        echo "<item>" . $line["product"] . "</item>\n";
        }
       
echo "</products>\n";  <<<<<< </disease_type> ??
0
 
SherryRzvAuthor Commented:
Thanks for your reply, so basically, I have to replace the above, into the the code? sorry for the q.
0
 
SherryRzvAuthor Commented:
Hi there, I followed the code you suggested.

This is what I got:

Not Found
The requested URL /Untitled-1.php was not found on this server.

Below is the reviewed code as I interpreted. Also inlcuded a screenshot of the PHP runnning in Dreamweaver. Kindly adivse

<?PHP

$link = mysql_connect("localhost","root", "??password??");
mysql_select_db("qof_codes");

$query = 'SELECT * FROM disease_type';
$results = mysql_query($query);

echo "<?xml version=\"1.0\"?>\n";
echo "<disease_type>\n"; <<<<< <disease_type>

while($line = mysql_fetch_assoc($results)) {
        echo "<item>" . $line["product"] . "</item>\n";
        }
       
echo "</products>\n";  <<<<<< </disease_type> ??
	
mysql_close($link);

?>

Open in new window

PHP.doc
0
All Courses

From novice to tech pro — start learning today.