Jump to content

Problem with a simple mysql and php script.


cwncool

Recommended Posts

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!

Link to comment
Share on other sites

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...

 

;)

Link to comment
Share on other sites

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... 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Guest prozente

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);

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.