954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Update Query is not Working..

Hi all
In my Application i have wrote an update query but its not working..Anybody plz help me here am including my code...

$head=$_GET['val'];
$date=$_REQUEST['txtdate'];
$headline=$_REQUEST['txthead'];
$update="Update tbl_circular SET date='$date',headline='$headline',description='$des' where headline like '$head')";
$update1=mysql_query($update) or die("Could not Update");

'val' is the querystring am passing to the page..

Then the die part of query is working ie its showing the error like "Could not Update"
Plz help...

jithusdani
Light Poster
47 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 

Hi,

I think you need to use wild card % and rephrase your sql query.

like %'.$head.'%

Are you not useing the . operator to create a dynamic query?

You can learn more about how to create a dynamic query at http://www.tutorialindia.com/php_mysql/php_mysql_update.php without . (Dot) operator your query is not dynamic and hence the error.

Also, be sure to create an sql date in correct format.

You need to
1. Create a dynamic query using the . dot operator.
2. Create the date correctly

You can remove the date field temporarily and update the query after sometime once your basic update is working. Feel free to send me a direct message in case of ny problem. I will answer within one day.

Hope this helps.

jsrpatna
Newbie Poster
15 posts since Jul 2008
Reputation Points: 10
Solved Threads: 2
 

Your update query should be like this:

$qur= "update tbl_circular set `date`='".$date."', `headline`='".$headline."', `description`='".$des."' where headline like  '%".$head."%'";	
$update1=mysql_query($update) or die("Could not Update");


Post if error occures...

Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
 

Your update query should be like this:

$qur= "update tbl_circular set `date`='".$date."', `headline`='".$headline."', `description`='".$des."' where headline like  '%".$head."%'";	
$update1=mysql_query($update) or die("Could not Update");

Post if error occures...

Hi,

This query might still have a little problem with the date field! Best thing would be to strip the query of date field, try the update query. When it works fine go for date.

Bye!

jsrpatna
Newbie Poster
15 posts since Jul 2008
Reputation Points: 10
Solved Threads: 2
 

Check your system date format with database date format...means yy-mm-dd like this...
Tel me what error you got...

Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
 

date is a mysql reserved keyword. Its better if you change the column name "date" to something else. If you don't want to change the column name, use ` around the column name. Oh, btw, if your query isn't still working, print your query and execute it in mysql console/phpmyadmin.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

i have got solution to applying the above code its working fine thnk u Shanti...

jithusdani
Light Poster
47 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 

welcome...
if u got solution make this thread as solved,then other will search solved threads....

Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You