作者:北若久 | 来源:互联网 | 2023-05-18 06:29
Iwanttoupdatevalueindbusingmysql_query().Icreatenewcustomer,thenifIwanttoupdatehi
I want to update value in db using mysql_query(). I create new customer, then if I want to update his name (or other values), it fails! So, first time only. If I refresh site with the same url, it works. Same code doesn't work first time, and second time it works. My question is whyyy?
我想使用mysql_query()更新db中的值。我创建新客户,然后如果我想更新他的名字(或其他值),它就失败了!所以,仅限第一次。如果我使用相同的网址刷新网站,它的工作原理。相同的代码第一次不起作用,第二次起作用。我的问题是为什么?
Connect to db is first step, when website loads.
当网站加载时,连接到db是第一步。
@mysql_connect(DBHOST, DBUSER, DBPASS) or die (mysql_error());
@mysql_select_db(DBNAME) or die (mysql_error());
mysql_query("SET CHARACTER SET utf8");
Next step is UPDATE (in this example id is hardcoded)
下一步是UPDATE(在此示例中,id是硬编码的)
$meno_z2=$_POST['firstnameko'];
$sql31888 = "UPDATE fitko_customer SET meno='".$meno_z2."' WHERE id=63";
mysql_query($sql31888) or die ('Error updating database: ' . mysql_error());
EDIT: Again, my code works. But for some reason it doesn't work at first time. 2nd, 3rd,.. time it works perfect! What other code do you need? First is connect, Second is mysql_query part. Here is all needed code: http://pastebin.com/itN6PURw
编辑:再次,我的代码工作。但由于某种原因,它在第一时间不起作用。 2号,3号,...它完美的时间!你需要什么其他代码?首先是连接,第二个是mysql_query部分。以下是所有需要的代码:http://pastebin.com/itN6PURw
1 个解决方案