0

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.

Edited by Ezzaral: Added code tags. Please use them to format any code that you post. Also removed db login info.

7
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by faroukmuhammad
0

Hi

please add the below line after mysql_query

$change=$_POST["reference_num"];

Let we check

0

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);
0

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 ' ' <--
0

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);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.