conor1 Posted April 9, 2013 Posted April 9, 2013 Hello, I created a mysql query,but it does not work. It outputs no errors , it just won't work. <?php Include('config.php'); mysql_query("INSERT INTO message(message) VALUES (' <font color=green><u>Test.....</u> </font>') or exit(mysql_error())"); ?> Before you ask, Table message does exist,and I know Font is deprecated.
Ice IT Support Posted April 10, 2013 Posted April 10, 2013 Try this: <?php include('config.php'); mysql_select_db('username_dbname'); mysql_query("INSERT INTO `message` (`message`) VALUES (' <font color=green><u>Test.....</u> </font>')") or exit(mysql_error()); ?> Be sure to change username_dbname to your values.
conor1 Posted April 10, 2013 Author Posted April 10, 2013 Hi Ice, Thank you for your reply. I did what you said, but it still won't work. There are also no errors being displayed.
Krydos Posted April 10, 2013 Posted April 10, 2013 Can you post the mysql related portions of config.php? Make sure you censor the password.
conor1 Posted April 10, 2013 Author Posted April 10, 2013 <?php$config['host'] = "localhost"; $config['user'] = "orb_orb"; $config['pass'] = "********"; $config['db'] = "orb_database";@mysql_connect("$config[host]","$config[user]","$config[pass]") or die("There was an error connecting to the database, MySql said:<br />".mysql_error()."");@mysql_select_db("$config[db]") or die("There was an error connecting to the database, MySql said:<br />".mysql_error()."");?> I'm sure there's nothing wrong in config.php, I use it on almost every file.
Ice IT Support Posted April 11, 2013 Posted April 11, 2013 Oh! Silly mistake on my end. The MySQL query isn't working because of special characters. <?php include('config.php'); $value = addslashes(' <font color=green><u>Test.....</u> </font>'); mysql_query("INSERT INTO `message` (`message`) VALUES ('$value')") or exit(mysql_error()); ?>
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now