cwncool Posted April 13, 2007 Share Posted April 13, 2007 I have a script to run SQL queries on my site. It's always worked before, but all the sudden it isn't working. I haven't done anything to the file. I did switch hosts a little while ago, but I can still run the queries through PHPMyAdmin, just not through my script. (No, I won't run them through PMA for this, I'd much rather use this script for speed. I have NO idea why it's not working. Can someone please tell me why? It's probably something simple that I'm just missing here. form.html: <form method="post" action="q2.php"> <textarea name="q" cols="70" rows="5"></textarea> <input type="submit" value="Send Query"> </form> q2.php <?php include '../connect.php'; // yes, this is the right connect file. it's a directory above this file. It's worked before. $q = $_POST['q']; mysql_query($q); //I've also tried this line like this: mysql_query("$q"); and it didn't make a difference header("location:form.html"); ?> I really just don't know why it's not working anymore. It's probably really simple. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/46932-problem-with-a-simple-mysql-and-php-script/ Share on other sites More sharing options...
PC Nerd Posted April 13, 2007 Share Posted April 13, 2007 can you echo out the $q variable ( i assume thats meant to be the sql?) check if its setting properly. also instead use $_REQUEST instead of post...... see what happens Quote Link to comment https://forums.phpfreaks.com/topic/46932-problem-with-a-simple-mysql-and-php-script/#findComment-228871 Share on other sites More sharing options...
MadTechie Posted April 13, 2007 Share Posted April 13, 2007 try @mysql_query($q) or MySQL_ErrorMsg ($q); Quote Link to comment https://forums.phpfreaks.com/topic/46932-problem-with-a-simple-mysql-and-php-script/#findComment-228872 Share on other sites More sharing options...
HeyRay2 Posted April 13, 2007 Share Posted April 13, 2007 You mentioned changing hosts recently. Did you update the information in your connect.php file to reflect the database connection information for your new host? If so, perhaps posting the code in your connect.php file here might lead us in the right direction for your issue... Quote Link to comment https://forums.phpfreaks.com/topic/46932-problem-with-a-simple-mysql-and-php-script/#findComment-228873 Share on other sites More sharing options...
cwncool Posted April 13, 2007 Author Share Posted April 13, 2007 Yes, I can echo the $q fine and it works. Yes, I did change that information. My whole site is based around MySQL and everything else is being called and displayed correctly, so the connect page works. The queries I'm running with this script are insert queries, and they aren't working. I've ran the insert queries from PMA though and they worked fine... Quote Link to comment https://forums.phpfreaks.com/topic/46932-problem-with-a-simple-mysql-and-php-script/#findComment-228883 Share on other sites More sharing options...
MadTechie Posted April 13, 2007 Share Posted April 13, 2007 try <?php include '../connect.php'; // yes, this is the right connect file. it's a directory above this file. It's worked before. $q = html_entity_decode($_POST['q'], ENT_QUOTES);; @mysql_query($q) or MySQL_ErrorMsg ($q); header("location:form.html"); ?> EDIT: updated Quote Link to comment https://forums.phpfreaks.com/topic/46932-problem-with-a-simple-mysql-and-php-script/#findComment-228886 Share on other sites More sharing options...
Guest prozente Posted April 13, 2007 Share Posted April 13, 2007 add this to the top of your php file and provide some error message(s) so this guessing game can stop ini_set('display_errors','1'); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/46932-problem-with-a-simple-mysql-and-php-script/#findComment-228891 Share on other sites More sharing options...
cwncool Posted April 14, 2007 Author Share Posted April 14, 2007 I tried adding the error checker, but it did not show any errors. What I'm thinking is that the new host has some feature in PHP or MySQL enabled or disabled that is doing something to prevent it from working. I really can't figure this out. haha. Quote Link to comment https://forums.phpfreaks.com/topic/46932-problem-with-a-simple-mysql-and-php-script/#findComment-229017 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.