Click here to Skip to main content
15,435,950 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
QuestionHow can I set the timestamp to 0? Pin
piano001114-Jun-18 2:38
Memberpiano001114-Jun-18 2:38 
Questionhow to add multiple sql queries? Do I need to join two queries? Pin
piano001110-Jun-18 17:50
Memberpiano001110-Jun-18 17:50 
Questionwhat is the difference between mysqli_stmt_num_rows and mysqli_num_rows? Pin
piano001110-Jun-18 17:49
Memberpiano001110-Jun-18 17:49 
AnswerRe: what is the difference between mysqli_stmt_num_rows and mysqli_num_rows? Pin
ishan_shah9-Mar-21 17:50
Memberishan_shah9-Mar-21 17:50 
Questionwhat is the difference between mysqli_stmt_fetch and mysqli_stmt_get_result Pin
piano001110-Jun-18 17:42
Memberpiano001110-Jun-18 17:42 
QuestionHow can I save a record into MySQL database while the data also prints on my POS printer Pin
Member 1369186123-May-18 8:03
MemberMember 1369186123-May-18 8:03 
QuestionSimple PHP MYSQL query problem Pin
Johannes Moolman19-May-18 4:43
MemberJohannes Moolman19-May-18 4:43 
AnswerRe: Simple PHP MYSQL query problem Pin
Jochen Arndt28-May-18 23:03
professionalJochen Arndt28-May-18 23:03 
Your question is meanwhile 10 days old but this might still help.

Quote:
i am watching tutorials on PHP and MYSQL but since the video and now SQL syntax changed
Don't use videos for learning programming. Most of them are of poor quality and some are telling you even wrong. Use books or web tutorials and read the official documentation for the used languages and functions (PHP: PHP Manual - Manual[^] and the documentation of the used database).

PHP
$uh=strtolower($_GET['uh']);
if($uh=='u'||$uh=='h'){
Never use == for string comparison. Use === or PHP: strcmp - Manual[^] to check for identity to avoid type juggling (see PHP: Comparison Operators - Manual[^]).

Always check for error return values and print error messages. This is especially useful with mysqli functions during development because you will get meaningful database error messages that help you finding syntax error in SQL query strings:
PHP
if ($result=mysqli_query($link, $sql)) {
    if (mysqli_num_rows($result)) {
        // Process rows here
    } 
    else {
        echo 'no results';
    }
} 
else {
    printf("SQL error: %s\n", mysqli_error($link));
}

Because $uh is a string and the healthy_unhealthy field probably too or a single character, you should enclose the value in single quotes in the query string:
PHP
$sql = "SELECT food,calories FROM food WHERE healthy_unhealthy = '". $uh . '" ORDER by id";

AnswerRe: Simple PHP MYSQL query problem Pin
SiFinances28-Oct-18 0:58
MemberSiFinances28-Oct-18 0:58 
QuestionProblem using accordian with table row Pin
Member 1382254218-May-18 22:23
MemberMember 1382254218-May-18 22:23 
QuestionHow to access text data from parent form to child form Using $_SERVER['PHP_SELF'] Pin
Member 1369186129-Apr-18 12:27
MemberMember 1369186129-Apr-18 12:27 
AnswerRe: How to access text data from parent form to child form Using $_SERVER['PHP_SELF'] Pin
Member 1393364531-Jul-18 22:02
MemberMember 1393364531-Jul-18 22:02 
Questionbarcode generator code Pin
Mayuri Konde28-Apr-18 1:55
professionalMayuri Konde28-Apr-18 1:55 
AnswerRe: barcode generator code Pin
SiFinances28-Oct-18 1:45
MemberSiFinances28-Oct-18 1:45 
QuestionHow to reduce the size of a php webpage form into POS-printer-friendly page Pin
Member 1369186126-Apr-18 5:26
MemberMember 1369186126-Apr-18 5:26 
QuestionHow to make data entered on a form that has not been submitted into MySql database appear on another form Pin
Member 1369186126-Apr-18 5:22
MemberMember 1369186126-Apr-18 5:22 
QuestionHow to use 4 digit incremental serial number on mysql database using PHP on my form Pin
Member 1369186126-Apr-18 2:16
MemberMember 1369186126-Apr-18 2:16 
AnswerRe: How to use 4 digit incremental serial number on mysql database using PHP on my form Pin
Jochen Arndt26-Apr-18 2:31
professionalJochen Arndt26-Apr-18 2:31 
GeneralRe: How to use 4 digit incremental serial number on mysql database using PHP on my form Pin
Member 1369186126-Apr-18 2:42
MemberMember 1369186126-Apr-18 2:42 
QuestionHow to use PHP global processing script action to process sumbitted data and display form data entered on the text on another page Pin
Member 1369186126-Apr-18 2:13
MemberMember 1369186126-Apr-18 2:13 
AnswerRe: How to use PHP global processing script action to process sumbitted data and display form data entered on the text on another page Pin
Richard MacCutchan26-Apr-18 2:49
mveRichard MacCutchan26-Apr-18 2:49 
QuestionHow to use a php $_SERVER['PHP_SELF'] to insert form data into Mysql database and redisplay data entered on another form Pin
Member 1369186126-Apr-18 2:11
MemberMember 1369186126-Apr-18 2:11 
QuestionPassword Verify Pin
Valecia_cho30-Mar-18 13:32
MemberValecia_cho30-Mar-18 13:32 
QuestionHow to call a reply forms using php. Pin
Member 1370467720-Mar-18 20:45
MemberMember 1370467720-Mar-18 20:45 
Questiondynamic question in php and mysql Pin
antonio_dsanchez9-Feb-18 10:24
Memberantonio_dsanchez9-Feb-18 10:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.