I'm lost!

Discussion in 'PHP' started by Sleeping Troll, Aug 14, 2008.

  1. #1
    <?php
    $Ref=$_GET["Ref"];
    $conn = mysql_connect("#######"); 
    mysql_select_db("#######",$conn);
    $result = mysql_query("Select FileName From ".$Ref."Where Enable = 1");
    while($row = mysql_fetch_array($result));
    {
    [COLOR="Red"]	echo "<img src=".$row['FileName']." width='100'>\r";[/COLOR]
    }
    ?>
    Code (markup):
    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/content/t/r/o/trollnest/html/bragflags/AJAX.php on line 8

    ?
     
    Sleeping Troll, Aug 14, 2008 IP
  2. CarcaBot

    CarcaBot Active Member

    Messages:
    389
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Tri this wai,,,
    <?php
    $Ref=$_GET['Ref'];
    $conn = mysql_connect("#######"); 
    mysql_select_db("#######",$conn);
    $result = mysql_query("Select FileName From $Ref  Where Enable = 1");
    while($row = mysql_fetch_array($result));
    {
    	echo "<img src=\"$row['FileName']\" width='100'>";
    }
    ?>
    PHP:
     
    CarcaBot, Aug 14, 2008 IP
  3. blood08

    blood08 Peon

    Messages:
    179
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    try this....

    
    <?php
    
    $Ref=$_GET["Ref"];
    
    $conn = mysql_connect("#######"); 
    
    mysql_select_db("#######",$conn);
    
    $result = mysql_query("Select FileName From ".$Ref."Where Enable = 1");
    
    while($row = mysql_fetch_array($result)){
    
    	echo "<img src=".$row['FileName']." width='100'>\r";
    
    } ?>
    
    Code (markup):
     
    blood08, Aug 14, 2008 IP
  4. blood08

    blood08 Peon

    Messages:
    179
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4

    LOL... Learn php!
     
    blood08, Aug 14, 2008 IP
  5. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #5
    One other fix:

    <?php
    $Ref=$_GET["Ref"];
    
    $conn = mysql_connect("#######"); 
    mysql_select_db("#######",$conn);
    
    $result = mysql_query("Select FileName From ".$Ref." Where Enable = 1");
    while($row = mysql_fetch_array($result))
    {
    	echo "<img src=".$row['FileName']." width='100'>\r";
    
    	// You can use this, too:
    	// echo "<img src=\"{$row['FileName']}\" width='100'>\r";
    }
    ?>
    PHP:
    Why are you taking the table name from the Query String? Some serious security problems going on there.
     
    jayshah, Aug 14, 2008 IP
  6. CarcaBot

    CarcaBot Active Member

    Messages:
    389
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #6
    Tri this is working 100%
    <?php
    $Ref=$_GET["Ref"];
    $conn = mysql_connect("localhost","user","password");
    mysql_select_db("database",$conn);
    $query = mysql_query("SELECT FileName from $Ref where Enable='1'");
    $row = mysql_fetch_array($query);
    
        echo "<img src='$row[FileName]' width='100'>";
    
    ?>
    PHP:
     
    CarcaBot, Aug 14, 2008 IP
  7. Property_Control

    Property_Control Peon

    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    You should always enclose variables that are in quotation marks with { and }
    example:

    $rawr = "Hey!";
    echo("Hello, the string is {$rawr}");
     
    Property_Control, Aug 14, 2008 IP
  8. php-lover

    php-lover Active Member

    Messages:
    261
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    58
    #8
    while($row = mysql_fetch_array($result));    //<-----you don't need that semicolon
    PHP:
     
    php-lover, Aug 15, 2008 IP