cnl83  
                
               
                 
              
                  
                    August 3, 2004,  3:01pm
                   
                   
              1 
               
             
            
              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?
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 3, 2004,  5:00pm
                   
                   
              2 
               
             
            
              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
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 3, 2004,  5:02pm
                   
                   
              3 
               
             
            
              I dont get that, but its not pasting into my text field like its soppose to.
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 3, 2004,  5:04pm
                   
                   
              4 
               
             
            
              As I was saying, post your own code, both of you… 
You get better chance of somebody helping you with that…  
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 3, 2004,  5:11pm
                   
                   
              5 
               
             
            
              <?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]”; 
?>
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 3, 2004,  5:12pm
                   
                   
              6 
               
             
            
              the only thing different in my file that is online is that i have the  myserver, username, pw filled in
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 3, 2004,  5:15pm
                   
                   
              7 
               
             
            
              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)
 
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 3, 2004,  5:21pm
                   
                   
              8 
               
             
            
              ya that parts cool…
line 20 is  “?>”   if i am not mistaken…there is no $  so i dunno whats up with that
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 3, 2004,  5:29pm
                   
                   
              9 
               
             
            
              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…  
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 3, 2004,  5:33pm
                   
                   
              10 
               
             
            
              that }  helped my problem
thanks cyan…
why is it almost every tutorial i do i find some typo 
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 3, 2004,  5:39pm
                   
                   
              11 
               
             
            
              Oh, come on…  They were just trying to help…  
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 4, 2004,  3:42pm
                   
                   
              12 
               
             
            
              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
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 4, 2004,  4:05pm
                   
                   
              13 
               
             
            
              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???
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 4, 2004,  4:07pm
                   
                   
              14 
               
             
            
              error: failed to execute query SELECT content FROM files WHERE filename=‘testfile’
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 4, 2004,  4:08pm
                   
                   
              15 
               
             
            
              dont i need something to select the database somewhere?
mysql_select_db(“database”,$link);   or something
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 4, 2004,  4:13pm
                   
                   
              16 
               
             
            
              when i type that url it just shows up
error : failed to execute query SELECT content FROM files WHERE filename=‘testfile’ 
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 4, 2004,  4:17pm
                   
                   
              17 
               
             
            
              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…  
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 4, 2004,  4:23pm
                   
                   
              18 
               
             
            
              when i add in the mysql_select and run that url it shows up
content=test1
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 4, 2004,  4:23pm
                   
                   
              19 
               
             
            
              well i didnt at first and then i did i dont know what happened
             
            
               
               
               
            
            
           
          
            
              
                system  
                
               
              
                  
                    August 4, 2004,  5:04pm
                   
                   
              20 
               
             
            
              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