Update Query is not Working..

Thread Solved

Join Date: May 2008
Posts: 45
Reputation: jithusdani is an unknown quantity at this point 
Solved Threads: 0
jithusdani jithusdani is offline Offline
Light Poster

Update Query is not Working..

 
0
  #1
Jul 15th, 2008
Hi all
In my Application i have wrote an update query but its not working..Anybody plz help me here am including my code...

  1. $head=$_GET['val'];
  2. $date=$_REQUEST['txtdate'];
  3. $headline=$_REQUEST['txthead'];
  4. $update="Update tbl_circular SET date='$date',headline='$headline',description='$des' where headline like '$head')";
  5. $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...
Last edited by Tekmaven; Jul 15th, 2008 at 12:54 pm. Reason: Code tags
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 13
Reputation: jsrpatna is an unknown quantity at this point 
Solved Threads: 2
jsrpatna jsrpatna is offline Offline
Newbie Poster

Re: Update Query is not Working..

 
0
  #2
Jul 15th, 2008
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_mys...sql_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.
Last edited by jsrpatna; Jul 15th, 2008 at 10:29 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,072
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: Update Query is not Working..

 
0
  #3
Jul 16th, 2008
Your update query should be like this:
  1. $qur= "update tbl_circular set `date`='".$date."', `headline`='".$headline."', `description`='".$des."' where headline like '%".$head."%'";
  2. $update1=mysql_query($update) or die("Could not Update");

Post if error occures...
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 13
Reputation: jsrpatna is an unknown quantity at this point 
Solved Threads: 2
jsrpatna jsrpatna is offline Offline
Newbie Poster

Re: Update Query is not Working..

 
0
  #4
Jul 16th, 2008
Originally Posted by Shanti Chepuru View Post
Your update query should be like this:
  1. $qur= "update tbl_circular set `date`='".$date."', `headline`='".$headline."', `description`='".$des."' where headline like '%".$head."%'";
  2. $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!
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,072
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: Update Query is not Working..

 
0
  #5
Jul 16th, 2008
Check your system date format with database date format...means yy-mm-dd like this...
Tel me what error you got...
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,739
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 330
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Update Query is not Working..

 
0
  #6
Jul 16th, 2008
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.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 45
Reputation: jithusdani is an unknown quantity at this point 
Solved Threads: 0
jithusdani jithusdani is offline Offline
Light Poster

Re: Update Query is not Working..

 
0
  #7
Jul 16th, 2008
i have got solution to applying the above code its working fine thnk u Shanti...
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,072
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: Update Query is not Working..

 
0
  #8
Jul 16th, 2008
welcome...
if u got solution make this thread as solved,then other will search solved threads....
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC