Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

transform MySQL result as a variable

Status
Not open for further replies.

cabernet

Technical User
Feb 24, 2003
75
PK
Hello
I work on a copy/ rename file system
the new file name must be a combo of index and of the id # that I got from a query
problem
how can I pass the resulitng id in a var named $ID
I need to pass that id value to $id
the sample below will explain my quest
how can I write $=... instead of my question marks
thank you

<?
$query = &quot;select id from stories where username= '$username' and password= '$password' &quot;;
$result= mysql_query ($query);
if ($username && $password == &quot;&quot;){
echo&quot;<b>Missing field try again</b>&quot;;
}
else
{
echo&quot;<b></b>&quot;;
}
$id= ????????

$old_file=&quot;index.php&quot;;
$new_file=&quot;index&quot;.$id. &quot;.php&quot;;

rename($old_file, $new_file);
 
I did it and post the answer for future ref

$old_file=&quot;index.php&quot;;

// pass ID value to index extension and add .php
while($query_data=mysql_fetch_array($result))
{
$new_file=&quot;index&quot;.$query_data[&quot;id&quot;]. &quot;.php&quot;;
}

rename($old_file, $new_file);
 
don't know why but brakets before and after &quot;id&quot; do not show
in the array
not my mistake I guess the post script escape brakets?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top