开发者

Cannot get PHP to execute MySQL query

Why doesn't my MySQL code work from PHP. However if I return the SQL and paste it into the SQL console the rows update accordingly.

SQL

UPDATE pro开发者_JAVA技巧pertypriority 
   SET prioritylevel = '8' 
 WHERE roomtypecode = '1184'; 

UPDATE property 
   SET prioritylevel = '8' 
 WHERE roomtypecode = '1184'; 

PHP

$sql = "UPDATE propertypriority 
           SET prioritylevel = '".$demotionvalue."' 
         WHERE roomtypecode = '".$row['roomtypecode']."'; "
       ."UPDATE property
            SET prioritylevel = '".$demotionvalue."' 
          WHERE roomtypecode = '".$row['roomtypecode']."'; ";


from: http://www.tutorialspoint.com/mysql/mysql-sql-injection.htm

'Fortunately, if you use MySQL, the mysql_query() function does not permit query stacking, or executing multiple queries in a single function call. If you try to stack queries, the call fails.'

so maybe try breaking it into two queries


I think you might want to look into wrapping your SQL statements into a transaction.

This page from the manual has a example for you.


Are you using mysqli? If so, depending on how you execute the query, it's not going to allow you to execute two statements with one command.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜