The newcomer consulted mysql+php page from the database to bring up the picture cannot display the problem

Source: Internet
Author: User
mysql+php page between the display picture problem, how to make the product name and corresponding picture normal display it.

1,index.php
....... Omitted in front

"Width=" height= "135" border= "3" >


Product Name:

<{$myrow [data].tb_commodity_id}>


<{$myrow [data].tb_commodity_name}>




2,head_picture.php
$query = "SELECT * from Tb_commodity where tb_commodity_id=". $recid;
$result =mysql_query ($query);
if (! $result) die ("Error:mysql query");
$num =mysql_num_rows ($result);
if ($num <1) die ("Error:no this recorder");
$data = mysql_result ($result, 0, "tb_commodity_picture");
Mysql_close ($conn);
Echo $data;
?>

3, the database table contains: Tb_commodity_id,tb_commodity_name,tb_commodity_picture field.

In the index page, the product name can display the database in the 5 data, including tb_commodity_id and Tb_commodity_name are normal display, only the picture can not display properly, if the head_picture.php inside $query= "SELECT * from Tb_commodity where tb_commodity_id=". $recid; Direct change to: $query = "SELECT * from Tb_commodity where tb_commodity_id=1", (or 2,3,4,5, that is, the corresponding tb_commodity_id in the database) to display the picture properly, There are currently 5 data in the database;
Change to: $query = "SELECT * from Tb_commodity where tb_commodity_id=". $myrow [data].tb_commodity_id; show tb_commodity_id=5 pictures;
Click on the index page can not display the picture, in the new tab to open the picture, the Address bar URL is: The machine name/head_picture.php?recid=5 (point recid corresponding to the picture, will show the corresponding recid), the page shows: Error:mysql Query


Reply to discussion (solution)

Native name/head_picture.php?recid=5 (point recid corresponding to the picture, will show the corresponding recid), the page is displayed: Error:mysql query

Focus here print out the SQL statement show look

Native name/head_picture.php?recid=5 (point recid corresponding to the picture, will show the corresponding recid), the page is displayed: Error:mysql query

Focus here print out the SQL statement show look


Print out the result is this, did not take the value of the. $recid to $query= "select * from Tb_commodity where tb_commodity_id=". $recid inside.
Error:mysql Query:select * from tb_commodity where tb_commodity_id=

$query = "SELECT * from Tb_commodity where tb_commodity_id=". $_get[' RecId '];

It's good to find the crux.
$recid, change to $_get[' RecId '];
or extract first ($_get);

OK, thanks @xuzuning and @anyilaoliu.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.