mysql 업데이트를 실행하기 전에 조건이 존재하는지 확인하려고합니다.MYSQL 쿼리를 실행하기 전에 조건을 확인하는 방법은 무엇입니까?
if (!mysql_query(
"UPDATE customers SET available_credit = available_credit where userid = '$userid';"
))
{
die('Sorry, a database error occurred');
}
을 ...하지만 난 이런 식으로 또 다른 조건을 추가하려고 해요 :이 코드는 아래 WORKS
if (!mysql_query && ($tradein_status == 'Accepted CREDIT')(
"UPDATE customers SET available_credit = available_credit where userid = '$userid';"
))
{
die('Sorry, a database error occurred');
}
작동하지 않습니다 요식 - 그것은이 오류가 발생합니다 " 구문 분석 오류 : 구문 오류, 예기치 않은 '('라인 235 "에 /home/bohemeth/public_html/tradeins/save_tradeins.php에서
이 부분입니다 왜 궁금 두 번째 것입니다
if (!mysql_query(
"UPDATE customers SET available_credit = available_credit where userid = '$userid';"
))
... 당신이 지금과 같은 조건 테스트를 위해 다른 곳 할 것 같다있는 상태 후 2 개 괄호와 중괄호로 작성되지 않은 :
if (!mysql_query){
"UPDATE customers SET available_credit = available_credit where userid = '$userid';"
}
어떤 도움을 주셔서 감사합니다!
'if (! mysql_query &&'. mysql_query()'는 함수입니다. – nickb
고마워. 닉. 그럼 뭐가 더 쓸데 있니? 외부 if 문과 함께 작동하는 문을 래핑합니까? ($ tradein_status == 'Accepted CREDIT') {if (! mysql_query ( "UPDATE customers SET available_credit = available_credit where userid = '$ userid';" )}) –
http://php.net/if ; http://php.net/expressions; http://php.net/operators --- 매뉴얼의 시작 부분에있는 PHP 언어 참고서에 모두 나와 있습니다. 나는 적어도 한 번 참조를 탈피하고 그것을 교차 읽는 것이 좋습니다. – hakre