Ok, I need help with two problems in the following set of code:

 $query="select * from `$album_id` where id='$id_count'";
$res=mysql_query($query) or die("Error");
$row = mysql_fetch_assoc($res);
$filename=$row[filename];
echo $res;
echo	$filename;
echo"<br>";
$file="$group_name \ $album_name \ $filename";
echo	$filename;
echo"<br>";
echo" <img src='$file'>";

my first problem is that I am having trouble with echo $res is giving me a Resoultion ID # instead of the contents, (I know I asked about this just recently, but the solution at that time does not seem to work here)

the second problem is that I want $file to store the contents of the 3 varibles, plus the slashes, but without the spaces, so for the only way I could get it to list the contents of the varibles plus the slashes is with the spaces in the string

thanks,
campsoup1988

PS: $album_id is the correct access to the table

    my first problem is that I am having trouble with echo $res is giving me a Resoultion ID # instead of the contents,

    That is what a mysql_query() function will do with a select statement if it works, otherwise it will return false. Here is what the manual says

    Return Values
    For SELECT, SHOW, DESCRIBE or EXPLAIN statements, mysql_query() returns a resource on success, or FALSE on error.

    You access the values through mysql_fetch_array() or mysql_fetch_assoc() and either of these will produce an array. So to answer your second part what you need to do is assign the values from the mysql_fetch_array() to different variables then create an array out of those variables and then implode them using implode() like this little example shows

    <?php 
    $string1='ok';
    $string2='notOK';
    $string3='alright';
    $new= array($string1,$string2,$string3);
    echo "<pre>";
    print_r($new);
    echo "</pre>";
    $slash_separated = implode("\\", $new);//must use two slashes because the backslash is an escape character
    echo $slash_separated; 
    ?>  

    Now with this example you should be able to get somewhere with your script.

      thank you! I will try your suggestion

      PS: I wish I had a copy of the manual, I think my teacher held back on them when I was in his class, just like the help files in mysql are missing (currently on summer break)

        Write a Reply...