<?php
$title=$_POST["title"];
$theme=$_POST["theme"];
$con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con) { die('Could not connect: ' . mysql_error()); }

mysql_select_db($dbname, $con);
$query=mysql_query("SELECT * FROM setup WHERE id=".$_SESSION['id']);
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
if ($num_rows > 0)
{
  while($row = mysql_fetch_array($result))
  {
    $_SESSION['id'] = $row['id'];
    $_SESSION['title']=$title['title'];
    $_SESSION['theme']=$theme['theme'];
    }
   {
mysql_query("UPDATE setup  SET title='".$title."' , theme='".$theme."'WHERE id=".$_SESSION['id']);
 header("Location:setup.php?status=1");
    }
}

//else {
    //header("Location:setup.php?status=2");
//}
mysql_close($con);
?>

this is my code for php setup-action and iam having problem for updating values in my sql and i cant understand the error please help :(

the error is on line 10 and 11

Warning: mysql_query() expects parameter 1 to be string, resource given in C:\xampp\htdocs\project\admin\setup-action.php on line 10

Warning: mysql_num_rows() expects parameter 1 to be resource, null given in C:\xampp\htdocs\project\admin\setup-action.php on line 11

Remove mysql_query from line 8. It is repeated on line 9.

its not repeated i've saved the query in $query and then saved it in $result would u please suggest me how should i do it correctly??
thanks for the rep :)

comment line 9 and replace $query with $result,becuase you can't execute query twice ,check this code:

$result=mysql_query("SELECT * FROM setup WHERE id=".$_SESSION['id']);
//$result = mysql_query($query);

excute this ,the error will be disapear.
%%^Murtada^%%

thankyou so much the error is gone...but now its saying undefined index on line 2 and 3..

i've fixed those errors as well :)

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.