i want to get image_id. which is store in database long blob. iam send a image id from different page to this page. and
i am using _GET to revice the image_id on this page.

$image_id = $_GET['img'];

but it say Undefined index: img

is there a different way to get image_id here?

note in my 2nd block of php code $image_id = $_GET['img']; this works ok.

full code...

<?php
include("include/header.php");

//grab submitted data
if($_SERVER['REQUEST_METHOD'] == 'POST') //if user add comment
{
    if(empty($_POST['comment']))
    {
    }
    else
    {
        $comment_p = $_POST['comment'];
        $user_id_s = $_SESSION['user_id'];

        $image_id = $_GET['img'];

        //success
        $comment = mysql_query("INSERT INTO comment VALUES(NULL,'$user_id_s','$image_id_g','comment_p')");
    }
}
else
{
}

?>


<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
    <link rel='stylesheet' type='text/css' href='css/top_menu.css' />
    <link rel='stylesheet' type='text/css' href='css/all_css.css' />
</head>

<body>
                <?php
                    $image_id = $_GET['img'];
                    $user_name_s = $_SESSION['username'];

                    //get image from database
                    $queryget = mysql_query("SELECT image FROM image WHERE image_id = $image_id");
                    $row = mysql_fetch_assoc($queryget);    
                    $image_db = $row['image'];
                    $src = "data:image/gif;base64," . $image_db;

                    //get image name from database
                    $queryget = mysql_query("SELECT image_short_name FROM image WHERE image_id = '$image_id'");
                    $row = mysql_fetch_assoc($queryget);    
                    $image_short_name_db = $row['image_short_name'];

                    //get image size from database
                    $queryget = mysql_query("SELECT image_des FROM image WHERE image_id = '$image_id'");
                    $row = mysql_fetch_assoc($queryget);    
                    $image_des_db = $row['image_des'];


                    //get image size from database
                    $queryget = mysql_query("SELECT image_size FROM image WHERE image_id = '$image_id'");
                    $row = mysql_fetch_assoc($queryget);    
                    $image_size_db = $row['image_size'];

                    //get image size from database
                    $queryget = mysql_query("SELECT image_resolution FROM image WHERE image_id = '$image_id'");
                    $row = mysql_fetch_assoc($queryget);    
                    $image_resolution_db = $row['image_resolution'];

                    //get image views from database
                    $queryget = mysql_query("SELECT image_view FROM image WHERE image_id = '$image_id'");
                    $row = mysql_fetch_assoc($queryget);    
                    $image_view_db = $row['image_view'];

                    //get image size from database
                    $queryget = mysql_query("SELECT image_comment FROM image WHERE image_id = '$image_id'");
                    $row = mysql_fetch_assoc($queryget);    
                    $image_comment_db = $row['image_comment'];

                    //get all comments
                    $result2 = mysql_query("SELECT * FROM comment WHERE image_id = '$image_id' ORDER BY image_id DESC");




                    echo"
                        <div id ='bg4'>
                            <div id='context4'>

                                <div class='image_nu'>
                                    <br/><img src=\"$src\"  class='image' /><br/><br/>
                                        <b><font color='#1d98d6'>" . $image_short_name_db . "</font></b><br/>
                                        <b><font color='#1d98d6'>By: " . $user_name_s . "</font></b><hr/>
                                </div>

                                <div id='image_des'>
                                     " . $image_des_db . "<br/><br/>
                                </div>

                                <div id='image_bottom'>
                                    <form class='form' action='zoom.php' method='post'>
                                        <b>".$user_name_s." - Add a Comment:</b><br/>
                                        <textarea class='textarea' name='comment' cols='50' > </textarea>
                                        <pre><input type='submit' class='button' name='submit' value='Add comment' /></pre>
                                     </form>
                                </div>

                                <div id='image_right'>
                                    <div id = 'nav2'>
                                        <ul>
                                            <li><a href='#'>Edit</a></li> 
                                            <li><a href='#'>Delete</a></li>
                                        </ul>
                                    </div>
                                </div>

                                <div id='image_right2'>
                                    <div class='form'>
                                        <b>>Satatic</font></b><br/>
                                        <b>View: " . $image_view_db . "</b><br/>
                                        <b>Comment: " . $image_comment_db . "</b><br/><hr/>
                                        Image information:<br/>
                                        <b>Size: " . $image_size_db . "</b><br/>
                                        <b>Resolution: " . $image_resolution_db . "</b><br/>
                                    </div>
                                </div>       

                                <div id='image_comment' class='form'> ";
                                        while($row2 = mysql_fetch_assoc($result2))
                                        {
                                            $comment_db = $row2['comment'];  //get comment from comment table
                                            $user_id_db = $row2['user_id'];  //get user id from comment table

                                            //get user name from user table
                                            $queryget = mysql_query("SELECT username FROM user WHERE user_id = '$user_id_db'");
                                            $row = mysql_fetch_assoc($queryget);    
                                            $user_name_db = $row['username'];

                                            echo"<font color='#CCCCCC'>$user_name_db</font><br/>";
                                            echo"$comment_db <hr/> <br/>";
                                        }
                            echo"</div>
                                <br/>
                            </div>
                        </div>
                    ";
                ?>
</body>

You can use this to test, if the img variable is passed or not:

$image_id = isset($_GET['img']) ? $_GET['img'] : 0;

Hello,
Just include below code after <?php tag...

$ebits = ini_get('error_reporting');

error_reporting($ebits ^ E_NOTICE);

Hiding possible problems is not a good way to code.

it works thanks alot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.