Jump to content

Recommended Posts

Hello...I want to know if this is possible, every time i try it says that query failed...any help?

 

<?php
if(isset($_POST['save']))
{
include 'library/config.php';
include 'library/opendb.php';


$querybox = $_POST['query_content'];


//Query
$sql = mysql_query("$querybox") or die('Error, query failed');

echo "Query entered!";

include 'library/closedb.php';
}

?>



<html>
<body>
<form method="post">
  <table width="700" border="0" cellpadding="2" cellspacing="1" align="center">
      <td width="100">Query Content:</td>
      <td><textarea name="query_content" cols="50" rows="10"></textarea></td>
    </tr>
      <td colspan="2" align="center"><input name="save" type="submit" value="GO!"></td>
    </tr>
  </table>
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/113372-query-box/
Share on other sites

Yes what you're doing is possible, aslong as you're entering a valid MySQL query in the textarea. To see why your query is failing chnage:

$sql = mysql_query("$querybox") or die('Error, query failed');

to

$sql = mysql_query($querybox) or die('Error, query failed<br ><b>Query:</b><pre>' . $querybox . '</pre><b>Error: </b>' . mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/113372-query-box/#findComment-582459
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.