View Full Version : Query running script =]
Romanity
21-12-2007, 05:18 PM
Heres the query;
INSERT INTO `script_settings` (`settingName`, `settingValue`, `settingLastUpdate`, `settingUpdatedBy`) VALUES ('script_version', '1.0', '$date $time', 'OurHabbo Systems')
Heres the page its running from;
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;
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?
Dentafrice,
21-12-2007, 05:27 PM
It has slashes in it, thats weird?
You use ` and ' too much to my liking.
<?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";
}
}
?>
Romanity
21-12-2007, 05:29 PM
haha whoops my bad... didnt even think of it =]
Ty
Dentafrice,
21-12-2007, 05:33 PM
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.
Romanity
22-12-2007, 01:44 PM
Oki, heres another prob...
Using forms.. I put this into database
<li><a href="$site_domain">Home</a></li>
Now, retrieving from database....
<?
$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???
Dentafrice,
22-12-2007, 02:32 PM
unset($site_domain);
Right before that
Romanity
22-12-2007, 02:44 PM
right before....?
Dentafrice,
22-12-2007, 02:48 PM
Right before the whole query.
Romanity
22-12-2007, 02:53 PM
<?
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
Dentafrice,
22-12-2007, 02:55 PM
Oh, well you can't just pull the HTML out and expect it to parse it as PHP variables..
<?
$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;
?>
Romanity
22-12-2007, 03:05 PM
Thank you =]
Romanity
22-12-2007, 04:14 PM
Using eregi_replace or str_replace.... is it possible to instead of doing it individually like you showed, to do say....
function replace($string)
{
eregi_replace("{", "$", "$string");
eregi_replace("}", "", "$string");
return $string;
}
because it makes it easier to do it that way, using a function ive definded... but when i did it, I got http://%7bsite_domain%7D/%7bfrontend_folder%7D as the end value....
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.