Sign in to follow this  

[web] Problem with running a MySQL query in PHP

Recommended Posts

Alright. I am trying to get a query to run on the website I am developing. THis is the last thing I need to do and I will be done. I have an update query in my page that will not run. Here is the code it belongs to:
newName = getcwd()."/".$_FILES['downloadPolicy']['name'];
	$fileName = $_FILES['downloadPolicy']['name'];
	$policy = mysql_real_escape_string($_POST['policy']);
	$deposit = mysql_real_escape_string($_POST['deposit']);
	$db = mysql_pconnect($dbhost,$dbuser,$dbpass);
	$query = "update rentalPolicy set policy = '{$policy}', depositAmount = {$deposit}, downloadPolicy = '{$fileName}'";
	$result = mysql_query($query);
		$message = "Rental Policy Updated";
		$message = "Rental Policy failed to Update";
includes.php has all the connection variables. They are all correct. I have checked the values of the three variables in the query. They all have a value. I have echoed out the final $query and ran that in the MySQL client and it works. Despite all that, every time I run the query through the page, it always errors out somehow and I get the "Rental Policy failed to Update" message. All the other update queries on my website work. It is only this one that is erroring out. Can anyone see what is wrong here?

Share this post

Link to post
Share on other sites
Never mind. I figured it out.

I was using the chdir() function to change the default directory so I could save the uploaded file. I forgot to change the default directory back. Without changing it back, I was using the wrong includes.php file and was not using the right user and permissions for the database.

I feel stupid, yet relieved.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this