I have a JavaScript calendar
<input type="text" size="8" id="date" name="calendar[]" />
When I input the following php it disables the calendar.
$result=mysql_query("select * from products where id='maui'");
while($row=mysql_fetch_array($result)){
but if I input the php without the "where clause" it works:
$result=mysql_query("select * from products");
while($row=mysql_fetch_array($result)){
What are some options for a work around?
I would imagine there is either a syntax error in you query, or the id
does not exist and therefore no results are returned. So always check the status of a database access call
$result=mysql_query("select * from products where id='maui'");
if ( $result === FALSE ) {
echo mysql_error();
exit;
}
if ( mysql_num_rows() == 0 ) {
echo 'No results returned';
exit;
}
while($row=mysql_fetch_array($result)){
Please dont use the
mysql_
database extension, it is deprecated (gone for ever in PHP7) Especially if you are just learning PHP, spend your energies learning thePDO
ormysqli_
database extensions, and here is some help to decide which to use
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.