Jump to content

Query Box


elflacodepr

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

Archived

This topic is now archived and is closed to further replies.

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