Question:
I need help in Query syntax in PHP?
Maha
2012-12-12 17:02:55 UTC
I just want to know what's the right way for writing query in php if anyone can help me to fix this syntax for updating the table "Event" it wont update the table even though there's no syntax error the browser accepted it !!!

$qry="UPDATE Event SET id='$event_id' , category_id= '$category' , title='$title' , image='$data' , datetime='$datetime' , location='$location' , description='$description' , tags='$tags' WHERE id='$event_id' AND category_id= '$category'";
Three answers:
rizal
2012-12-12 17:09:37 UTC
Have you tried excluding the variables from strings?

I mean like

$qry="UPDATE Event SET id='$event_id' , category_id= '$category' ,

become

$qry="UPDATE Event SET id='" .$event_id. "' , category_id= '" .$category. "' ,
Larisa
2012-12-13 01:12:13 UTC
You have to create HTML form to submit the data event_id,category,title etc. Now create bellow php file with necessary alterations with your database name,password etc


$event_id=$_POST['event_id'];

$category=$_POST['category'];

$title=$_POST['title'];

$data=$_POST['data'];

$datetime=$_POST['datetime'];

$location=$_POST['location'];

$description=$_POST['description'];

$tags=$_POST['tags'];

$con = mysql_connect("localhost","root","");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}



mysql_select_db("your_database", $con);



mysql_query("UPDATE Event SET id='$event_id' , category_id= '$category' , title='$title' , image='$data' , datetime='$datetime' , location='$location' , description='$description' , tags='$tags' WHERE id='$event_id' AND category_id= '$category'");



mysql_close($con);

echo "sucessfully updated";

?>
anonymous
2016-11-25 02:25:15 UTC
this is a database question. you're able to now no longer convert it to very own living house internet site code. you have 2 ideas: a million. connect on your database administration application and paste and run that code as an sq. question. 2. Use very own living house internet site to connect with database and run that query. i desire to point the 1st determination


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...