-1

this is code of the page that I will get the image from(work perfectly)

<?php
    ob_start();
    session_start();
    include('connect.php');

    $id = $_GET['id'];
    $query = mysql_query("SELECT * FROM news WHERE id=$id");
    $row = mysql_fetch_assoc($query);

    header("Content-type: image/jpeg");
    echo $row['image'];
?>

and this is my page that i get the image to in

<?php
    ob_start();
    session_start();
    include('includes/connect.php');
    include('includes/phpCodes.php');

    $id = $_GET['id'];

    function showNews() {
        $data = array( 'id' => $id );
        $base = "includes/getImage.php";
        $url = $base. "?" . "id=36";
        echo $url;
        echo '<img src=includes/getImage.php class="newsImage">';
        echo '<h1><p class="subjecTitle">هنا العنوان</p></h1>   
                 <div class="newsContent">
                    hihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihi
             </div>
        ';
    }
?>

<!DOCTYPE html>
<html>
    <head>
        <title>عينٌ على الحقيقة</title>

        <meta charset="utf-8">

        <link rel="stylesheet" type="text/css" href="css/mainstyle.css">
        <link rel="stylesheet" type="text/css" href="css/showstyle.css">
        <script lang="javascript">
            function logout( myFrame ) {
                myFram.submit();
            }
        </script>
    </head>
    <body>
        <div class="wrapper">
            <?php headerCode(); ?>
            <div class="content" dir="rtl">
                <?php showNews(); ?>
            </div>
        </div>
    </body>
</html> 

i think my wrong is in , can someone tell me how can I solve it?, sorry for my bad english

Tepken Vannkorn
  • 9,648
  • 14
  • 61
  • 86
Bassam Badr
  • 667
  • 4
  • 16
  • 25

3 Answers3

1

Cleared it up for you:

echo '<img src="includes/getImage.php?id=' . $id . '" class="newsImage">';

Should 100% work (if the $id param has a value of course).

Update to fix the missing $id var:

    <?php
        ob_start();
        session_start();
        include('includes/connect.php');
        include('includes/phpCodes.php');

        $id = $_GET['id'];

        function showNews(){
            $id = $_GET['id'];
            $base = "includes/getImage.php";
            $url = $base. "?" . "id=36";
            echo $url;
            echo '<img src="includes/getImage.php?id=' . $id . '" class="newsImage">';

            echo '
                <h1><p class="subjecTitle">??? ???????</p></h1> 
                <div class="newsContent"></div>
            ';
        }
    ?>
Remko
  • 968
  • 6
  • 19
  • Parse error: syntax error, unexpected '>' in C:\AppServ\www\Eye\show.php on line 15 – Bassam Badr Jul 30 '13 at 07:19
  • Are you positive your source looks exactly the same as provided by me? This will work and will not generate an error. Please show me your code as it looks like now. – Remko Jul 30 '13 at 07:23
  • See this working example: http://phpfiddle.org/lite/code/2h3-7ck and press 'run' to the right. Will result in a img tag without parsing errors. Are you sure you have exactly the same string on line 15? – Remko Jul 30 '13 at 07:28
  • it works but the image didn't display – Bassam Badr Jul 30 '13 at 07:43
  • the sourc look like this – Bassam Badr Jul 30 '13 at 07:45
  • The $id var was empty in that case and I see why (see my updated code) – Remko Jul 30 '13 at 07:46
  • I would like to add that the code is not safe for exploits (using unescaped $_GET data) see also: http://stackoverflow.com/questions/1695973/php5-security-get-post-parameters – Remko Jul 30 '13 at 07:51
  • after 10 hours of work :) Now it's work im so so so happy, thank you so much brother – Bassam Badr Jul 30 '13 at 08:00
0

Change :

echo ' <img src=includes/getImage.php class="newsImage">';

To :

echo ' <img src="includes/getImage.php?id='.$id.'" class="newsImage">';

Please note src has " and also make sure that includes/getImage.php return a image path

Prasanth Bendra
  • 31,145
  • 9
  • 53
  • 73
0

why are you using two different pages? put both code in single page and simply do this

 <img src=includes/<?php echo $row['image']; ?> class="newsImage">
chirag ode
  • 950
  • 7
  • 15