Results 1 to 4 of 4

Thread: PHP Syntax Error

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Location
    New York
    Posts
    74

    Angry PHP Syntax Error

    From the following code I am trying to grab the URL in my mysql database. Whats wrong with my code? It grabs the "logo" but how do I turn that into an iamge so it appears on my page?

    PHP Code:
    <?php
    $sql 
    mysql_query("SELECT * FROM `ALEast` ORDER BY `id` ASC");

    while( 
    $row mysql_fetch_assoc($sql) ) { 
         echo 
    '<tr class="A"> 
        <td>' 
    $row['logo'] . '</td>
        <td>' 
    $row['W'] . '</td>
        <td>' 
    $row['L'] . '</td> 
        <td>' 
    $row['PCT'] . '</td> 
        <td>' 
    $row['GB'] . '</td> 
      </tr>'

    }
    ?>
    Last edited by rgyankees23; Aug 14th, 2008 at 05:50 PM.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: PHP Syntax Error

    You need to use a separate page which queries only the logo form the database and outputs it with the appropriate Content-Type, i.e image/gif. Also, there is no need to use echo to produce HTML:
    PHP Code:
    <?php while( $row mysql_fetch_assoc($sql)): ?>
        <tr class="A">
            <td><img src="get_logo.php?id=<?php echo($row['id']) ?>" alt="Logo" ></td>
            <td><?php echo($row['W']) ?></td>
            <td><?php echo($row['L']) ?></td>
            <td><?php echo($row['PCT']) ?></td>
            <td><?php echo($row['GB']) ?></td>
        </tr>
    <?php endwhile; ?>
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: PHP Syntax Error

    Quote Originally Posted by rgyankees23
    From the following code I am trying to grab the URL in my mysql database. Whats wrong with my code? It grabs the "logo" but how do I turn that into an iamge so it appears on my page?

    PHP Code:
    <?php
    $sql 
    mysql_query("SELECT * FROM `ALEast` ORDER BY `id` ASC");

    while( 
    $row mysql_fetch_assoc($sql) ) { 
         echo 
    '<tr class="A"> 
        <td>' 
    $row['logo'] . '</td>
        <td>' 
    $row['W'] . '</td>
        <td>' 
    $row['L'] . '</td> 
        <td>' 
    $row['PCT'] . '</td> 
        <td>' 
    $row['GB'] . '</td> 
      </tr>'

    }
    ?>
    Your syntax error is cause by the presence of array variables in your string. you need to enclose these in curly brackets:
    PHP Code:
    echo "Test {$array['index']}"
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Location
    New York
    Posts
    74

    Re: PHP Syntax Error

    http://robbyzworld.com/personal/Yank...tstandings.php

    Where you see the link, its suppose to be that image.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width