An error occurred while reading data from the MySQL table. mysql select php
Below is a piece of code that works normally
/* Inject basic information. A_ I automatically generates meta_id */$ query1 = "INSERT INTO libr_metacode (meta_isbn, meta_cip) VALUES ('$ isbn', '$ cip ')"; $ result1 = mysqli_query ($ dbc, $ query1) or die ('unable to write the basic encoding, error message :'. mysqli_error ($ dbc);/* obtain meta_id for subsequent writing */$ query = "SELECT * FROM libr_metacode WHERE meta_isbn = '$ isbn '"; $ result = mysqli_query ($ dbc, $ query); $ row = mysqli_fetch_array ($ result); $ ida = $ row ['meta _ id']; echo 'obtain the metadata of the library system in this book '. $ ida.'
';/* Title */$ query2 = "insert into libr_title (meta_id, title, subtitle, series) VALUES (' $ ida ',' $ title', '$ title ', '$ series') "; $ result2 = mysqli_query ($ dbc, $ query2) or die ('title information cannot be written, error :'. mysqli_error ($ dbc ));
What we do is:
1. Insert the ISBN number (International Standard Book Number) and CIP number obtained in the form into the meta_code table.
2. use the unique ISBN number to query the system metadata obtained by books in the meta_code table.
3. Insert data into multiple tables using system metadata
Because ISBN has 13 bits and is not suitable for primary keys ?), So this is done, but when reading other data, almost identical query code will go wrong.
/* Get meta_id for subsequent writing */$ query = "SELECT * FROM '$ ui_ B' WHERE '$ ui_c' = '$ ui_a'"; $ result = mysqli_query ($ dbc, $ query); $ row = mysqli_fetch_array ($ result); $ ida = $ row ['meta _ id'];
Error: mysqli_fetch_array () expects parameter 1 to be mysqli_result, boolean given.
Although we know that $ result should return a resource id, we can use fetch_array () in the first code. why must fetch_array () be a logical value in the second code?
Also, how can I "echo" the value of $ result?
Reply to discussion (solution)
Supplement: The system metadata is automatically incremented by A_ I. $ ui_a inputs the field value, $ ui_ B inputs the table name, and $ ui_c inputs the column name.
If $ ui_ B is the table name and $ ui_c is the field name
Writing
$ Query = "SELECT * FROM $ ui_ B WHERE $ ui_c = '$ ui_a '";
If $ ui_ B is the table name and $ ui_c is the field name
Writing
$ Query = "SELECT * FROM $ ui_ B WHERE $ ui_c = '$ ui_a '";
I'm going ...... That's right ...... Thank you!