Jump to content

Mysql Query , Not Working?


Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

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());
?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...