PDA

View Full Version : anyone with PHP experience want to tell me what's wrong,,,



upuaut8
April 20th, 2002, 02:29 PM
...with this script

include_once ("filelock/db_include.php");
//make connection
$connect = mysql_connect($db_host,$db_user,$db_password);
//select database
mysql_select_db($db_name,$connect);
//query table
$result=mysql_query("SELECT * FROM $table_name,$connect);
$counter=0;
while ($myrow = mysql_fetch_array($result)){
printf("&date$counter=%s&name$counter=%s&email$counter=%s&site$counter=%s&comment$counter=%s",rawurlencode($myrow["date"]),rawurlencode($myrow["name"]),rawurlencode($myrow["email"]),rawurlencode($myrow["site"]),rawurlencode($myrow["comment"]));
$counter++;
}
$flag="&flag=true";
echo "$flag";

I'm getting a parse error on line 11.. which in the case of the script above is line 10 because I left off the php opener and closer tags. So it's the "printf" line

eyezberg
April 20th, 2002, 02:37 PM
Im just gettin' started with php, never used mySql before, so..

1. what's the f in printf for?
2; "while ($myrow = mysql_fetch_array($result)){" looks weird to my unknowing eyeZ; you use a single = and where does the loop get incremented?

Just guessing..

PS: you should ask 'bout this at www.phpforflash.com , good forum..)

upuaut8
April 20th, 2002, 02:59 PM
there's a counter++ at the bottem

the printf command comes from Flash Developer's Guide.

Really all I want to do is query the table and then send all that data to flash.. every row, every column.. If you have another script that would work better, I'd be happy to use it instead.

eyezberg
April 21st, 2002, 01:20 AM
"there's a counter++ at the bottem" ..
yes, but where is it used in the while so the condition check ever gets false?

upuaut8
April 21st, 2002, 09:10 AM
Well.. I got it working.. so I know it works.. :)

while ($myrow = mysql_fetch_array($result)){
printf("&date$counter=%s&name$counter=%s&email$counter=%s&site$counter=%s&comment$counter=%s",rawurlencode($myrow["date"]),rawurlencode($myrow["name"]),rawurlencode($myrow["email"]),rawurlencode($myrow["site"]),rawurlencode($myrow["comment"]));
$counter++;
}

the counter incriments every time the script runs through. the counter itself though, is not what stops the loop, its the mysql_fetch_array command that does that. The counter is just there to add a unique number to the end of each of the array items.