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. Quote
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. Quote
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. Quote
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. Quote
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. Quote
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()); ?> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.