I cant get this tutorial..can someone help

Im trying to use http://www.kirupa.com/developer/actionscript/flash_php_mysql.htm

I tried page one and two, I cannot get it to work for me though.
The only thing I did different was upload it to my web site instead of local. So the URL was direct (test.php) instead of http://localhost stuff…

Can someone give me a hand on this?

i get this error on mine

Parse error: parse error, unexpected $ on line 20

all i did was copy the code straight out of the tutorial but put in my own db location username and password

I dont get that, but its not pasting into my text field like its soppose to.

As I was saying, post your own code, both of you…
You get better chance of somebody helping you with that… :slight_smile:

<?php
//read.php
//prints contents of content column where filename = $file

if($file) {
$link = mysql_connect(mysever, username, pw)
or die("<b>error</b>: failed to connect to database");

$query = “SELECT content FROM files WHERE filename=’$file’”;
$result = mysql_query($query)
or die("<b>error</b>: failed to execute query <i>$query</i>");

mysql_close($link);

$desiredContent = mysql_fetch_array($result, MYSQL_ASSOC);

mysql_free_result($result);

print “content=$desiredContent[content]”;
?>

the only thing different in my file that is online is that i have the myserver, username, pw filled in

If you use PHP tag, it’d be whole lot easier to read your code…

The only thing I can see at the moment is this line…


$link = mysql_connect(mysever, username, pw)

If mysever, username and pw are the strings, it has to be this…


$link = mysql_connect("mysever", "username", "pw")

and it had to be this if they are variable…


$link = mysql_connect($mysever, $username, $pw)

ya that parts cool…

line 20 is “?>” if i am not mistaken…there is no $ so i dunno whats up with that

Well… Another one is that the script contains ‘{’ but there is no ‘}’, hence you get error message on line 20…

I can’t help you much cuz I do not understand what ptolemy wanted to achieve with that PHP script…(I am not good at PHP either and I have no idea what that $file is supposed to be…)

Why don’t you contact the author to see if he can help you??? I think that’s your best bet… :wink:

that } helped my problem

thanks cyan…

why is it almost every tutorial i do i find some typo :stuck_out_tongue:

Oh, come on… They were just trying to help… :slight_smile:

my php seems to be working fine…if i run it by itself i get no errors

 
<?php
//read.php 
//prints contents of content column where filename = $file
if ($file) {
$link = mysql_connect("dbhost", "login", "pw")
			or die("<b>error</b>: failed to connect to database");
$query = "SELECT content FROM files WHERE filename='$file'";
$result = mysql_query($query) 
			 or die("<b>error</b>: failed to execute query <i>$query</i>");
mysql_close($link); 
$desiredContent = mysql_fetch_array($result, MYSQL_ASSOC);
mysql_free_result($result);
print "content=$desiredContent[content]";}
?>

and then on my flash file is

onClipEvent (load) {
loadVariables("[http://www.mydomain.com/test/read.php?file=testfile](http://www.mydomain.com/test/read.php?file=testfile)", this, "GET");
}

but its not reading the data from the database
does anything look wrong here or is it something with my db

Okay… You have this script…


<?php
	//read.php 
	//prints contents of content column where filename = $file
	if ($file)
	{
		$link = mysql_connect("dbhost", "login", "pw")
			or die("<b>error</b>: failed to connect to database");
		$query = "SELECT content FROM files WHERE filename='$file'";
		$result = mysql_query($query) 
			or die("<b>error</b>: failed to execute query <i>$query</i>");
		mysql_close($link); 
		$desiredContent = mysql_fetch_array($result, MYSQL_ASSOC);
		mysql_free_result($result);
		print "content=$desiredContent[content]";
	}
?>

What do you get when you type ‘http://www.mydomain.com/test/read.php?file=testfile’ from the IE???

error: failed to execute query SELECT content FROM files WHERE filename=‘testfile’

dont i need something to select the database somewhere?

mysql_select_db(“database”,$link); or something

when i type that url it just shows up

error: failed to execute query SELECT content FROM files WHERE filename=‘testfile’

Indeed, you do need to add this line…


mysql_select_db("database name", $link);

when i type that url it just shows up a blank page

You just said that you were getting an error message… Make up your mind… :stuck_out_tongue:

when i add in the mysql_select and run that url it shows up

content=test1

well i didnt at first and then i did i dont know what happened

ya i added the mysql_select and i also took the loadVariables and put it on my first frame rather than on the movie clip
and it works great now

thanks again cyan :smiley: