Advertisement Jump to content
Sign in to follow this  

[web] Problem with running a MySQL query in PHP

This topic is 3831 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!