Error reading data from MySQL table

Source: Internet
Author: User
MySQL Select PHP

Here's a piece of code that works fine
/* Inject basic information, a_i automatically generate meta_id */$query 1 = "INSERT into Libr_metacode (META_ISBN, Meta_cip) VALUES (' $isbn ', ' $cip ')"; $result 1 = Mysqli_query ($DBC, $query 1)  or Die (' cannot write basic encoding, error message: '. Mysqli_error ($DBC));/* Get meta_id for subsequent writes */$query = "SELECT * FR OM libr_metacode WHERE meta_isbn= ' $isbn ' "; $result = Mysqli_query ($dbc, $query); $row = Mysqli_fetch_array ($result); $ida = $row [' meta_id '];echo ' get the book Library system meta-code '. $ida. '
'; /* Title */$query 2 = "INSERT into Libr_title (meta_id, title, subtitle, series) VALUES (' $ida ', ' $title ', ' $subtitle ', ' $seri Es ') "; $result 2 = Mysqli_query ($dbc, $query 2) or Die (' cannot write the title information, Error: '. Mysqli_error ($DBC));


The thing to do is:

1. The ISBN Number (ISBN), the CIP number, which is obtained by the form, insert the line System Meta Code ISBN number in the Meta_code table
2. Use the unique ISBN number to query the system meta-codes obtained in the Meta_code table
3. Inserting in multiple tables with system meta-coding

Because ISBN has 13 bits not suitable for the master key (right?) ), so I did it, but the query code, which was almost identical when reading other data, went wrong.

/* Get meta_id for subsequent writes */$query = "select * from ' $ui _b ' WHERE ' $ui _c ' = ' $ui _a '"; $result = Mysqli_query ($dbc, $query); $row = My Sqli_fetch_array ($result); $ida = $row [' meta_id '];


Error: Mysqli_fetch_array () expects parameter 1 to be Mysqli_result, boolean given.

Although know $result should return is a resource ID but in the first paragraph of code Fetch_array () clearly can ah, why the second code in the Fetch_array () must be logical value?

Also, ask how can "echo" out the value of $result?


Reply to discussion (solution)

Add: The system meta-code is automatically incremented a_i, $ui _a input is the field value, $ui _b input is the table name, $ui _c input is the column name.

If $ui _b is a table name, $ui _c is the field name
You should write
$query = "SELECT * from $ui _b WHERE $ui _c= ' $ui _a '";

If $ui _b is a table name, $ui _c is the field name
You should write
$query = "SELECT * from $ui _b WHERE $ui _c= ' $ui _a '";
I'll go...... Yes, it is. Thank you Moderator!

  • 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.