I don't know why can't I update?

Coding show as below:

<?php 
$con = mysql_connect("example.com","user","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("germanpo_gpweb", $con);


 $refnum = $_POST['reference_num'];
 $recetel = $_POST['receiver_tel'];
	

mysql_query("UPDATE `order` 
 SET `receiver_tel`  = '".$recetel."'
WHERE `reference_num`  = '".$refnum."'");

mysql_close($con);
?>

<p align="center"><? echo "$refnum , $recetel"; ?></p>

I can show $refnum and $recetel value on web page.
And I make sure database table name is order. Two field receiver_tel and reference_num are correct.

Man, dum da dum, read your private messages! :D

Debug by adding the line

echo mysql_error();

to see what you get.

Hi

please add the below line after mysql_query

$change=$_POST["reference_num"];

Let we check

I think your $refnum is comming blank or invalid.
Echo this query and run it in phpmyadmin.

echo $sql = "UPDATE `order` SET `receiver_tel`  = '".$recetel."' WHERE `reference_num`  = '".$refnum."'" ; exit
mysql_query($sql);

if reference_num is an int type in your database it will not update because of the tick marks around $refnum.

$sql = "UPDATE `order` SET `receiver_tel`  = '".$recetel."' WHERE `reference_num`  = ".$refnum.";
// lose the ticks ' ' <--

You forgot to add the connection id to the mysql_query, therefore line 15 suppose to be;

mysql_query("UPDATE `order` 
 SET `receiver_tel`  = '".$recetel."'
WHERE `reference_num`  = '".$refnum."'", $con);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.