-
Query running script =]
Heres the query;
PHP Code:
INSERT INTO `script_settings` (`settingName`, `settingValue`, `settingLastUpdate`, `settingUpdatedBy`) VALUES ('script_version', '1.0', '$date $time', 'OurHabbo Systems')
Heres the page its running from;
PHP Code:
if(!$_POST["submit"]){
echo "<form method=POST>
SQL:<br>
<textarea name='sql' rows='10' cols='50'></textarea><br><br>
<input type='submit' name='submit' value='Run Query'>
</form>";
}else{
$sql = $_POST[sql];
$query = mysql_query($sql) or die(mysql_error());
if($query){ echo "Query successfully ran"; }else{ echo "There was a problem running the query"; }
}
(Yes its connected to the database)
& heres the error;
PHP Code:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'script_version\', \'1.0\', \'$date $time\', \'OurHabbo Systems\')' at line 1
Any reason why its not working?
-
It has slashes in it, thats weird?
You use ` and ' too much to my liking.
PHP Code:
<?php
if (!$_POST["submit"]) {
echo "<form method=POST>
SQL:<br>
<textarea name='sql' rows='10' cols='50'></textarea><br><br>
<input type='submit' name='submit' value='Run Query'>
</form>";
} else {
$sql = $_POST["sql"];
$sql = stripslashes($sql);
$query = mysql_query($sql) or die(mysql_error());
if ($query) {
echo "Query successfully ran";
} else {
echo "There was a problem running the query";
}
}
?>
-
haha whoops my bad... didnt even think of it =]
Ty
-
Depending on your server settings it usually adds slashes to (')'s
so \'hey\' just like when you put " inside of a " declaration in PHP.
So you must first strip those, if you want it to be executed properly.
-
Oki, heres another prob...
Using forms.. I put this into database
PHP Code:
<li><a href="$site_domain">Home</a></li>
Now, retrieving from database....
PHP Code:
<?
$nav = mysql_fetch_array(mysql_query("SELECT * FROM `script_templates` WHERE `templateID` = '3'"));
$templateHTML= stripslashes($nav[templateHTML]);
echo "$templateHTML";
?>
How do i stop it from echoing $site_domain.... but the variable for $site_domain that i have defined previously???
-
unset($site_domain);
Right before that
-
-
Right before the whole query.
-
PHP Code:
<?
unset($site_domain);
$nav = mysql_fetch_array(mysql_query("SELECT * FROM `script_templates` WHERE `templateID` = '3'"));
$templateHTML= stripslashes($nav[templateHTML]);
echo "$templateHTML";
?>
Still returns a URL link of http://$site_domain/ instead of what $site_domain is set as... yourdomain.com
-
Oh, well you can't just pull the HTML out and expect it to parse it as PHP variables..
PHP Code:
<?
$nav = mysql_fetch_array(mysql_query("SELECT * FROM `script_templates` WHERE `templateID` = '3'"));
$templateHTML = stripslashes($nav[templateHTML]);
$templateHTML = str_replace("{site_domain}", $site_domain, $templateHTML);
echo $templateHTML;
?>