简体   繁体   English

mysql查询无法通过php工作 由phpmyadmin工作

[英]mysql query doesnt work by php | work by phpmyadmin

One of my PHP functions just not work. 我的PHP函数之一无法正常工作。 Mysql returns success but it doesnt UPDATE column that i want. MySQL返回成功,但它没有我想要的UPDATE列。 I really no have idea why that problem exist. 我真的不知道为什么存在这个问题。

So here is the function that UPDATING it: 因此,这是更新它的功能:

function savePhone($phone) { 函数savePhone($ phone){

 dbConnect(); $q = "UPDATE site SET phone = '$phone' WHERE id = 0"; $r = mysql_query($q) or die (mysql_error()); if ($r) return $q; else return "error"; 

} }

Here is var_dump-ed example query that works fine when using phpMyAdmin. 这是var_dump-ed示例查询,在使用phpMyAdmin时可以正常工作。

'UPDATE site SET phone = '111111' WHERE id = 0' '更新站点设置电话='111111'WHERE ID = 0'

Im using Apache 我正在使用Apache

This is wrong actually die() stops the script from executing 这是错误的,实际上die()阻止了脚本的执行

$r = mysql_query($q) or die (mysql_error());

if die() is called this part is never gonna be executed and no value is returned to $q 如果调用die(),则永远不会执行此部分,并且不会将任何值返回到$ q

if ($r) return $q; 
  else return "error"; 
}

use instead 用代替

$r = mysql_query($q);

if(empty(mysql_error())) return $q;
   else return "error";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM