Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Php Help: Mysql Warning


3 replies to this topic

#1 Hamtaro

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 372 posts
  • Interests:Watching Hamtaro, working on computers, programming, website designing (this one should be obvious).
  • myCENT:ZERO

Posted 22 January 2005 - 12:00 AM

I've just made a PHP script that allows people to chat. It's similar to a tag-board (But not exactly). I'm getting the following warning with MySQL:
Warning: Unexpected character in input: '' (ASCII=31) state=1 in /home/hamtaro/public_html/add_message.php on line 12

I looked in the file, and didn't find anything...So I thought I'd ask for help (again).

Here's the code:
<?php
$UserName = $_POST['UserName'];
$EMail = $_POST['EMail'];
$Message = $_POST['Message'];
$IP = $REMOTE_ADDR;

$Query = "INSERT INTO chatboard (UserName, IP, EMail, Message) values('$UserName', '$IP', '$EMail', '$Message')";

include "db_chat.php"; //Database connection file

mysql_query($Query);

mysql_close();

include "chat.php";
?>

The weird thing is...this works the way it should...it adds to the database, and also reads it (chat.php), yet I still get that warning. Does anyone know why it's showing that?

#2 OpaQue

    Administrator

  • Admin - The Official Guru
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 1,895 posts
  • Gender:Male
  • Location:Somewhere in Time & Space.
  • Interests:Discovering Myself.
  • myCENT:-129.97

Posted 22 January 2005 - 12:13 AM

Reemove the Special character on line 12

#3 Hamtaro

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 372 posts
  • Interests:Watching Hamtaro, working on computers, programming, website designing (this one should be obvious).
  • myCENT:ZERO

Posted 22 January 2005 - 12:35 AM

I can't find it. I know what it's talking about, and the line is: mysql_query($Query); but the single quotes around the variables to write to the database are required. Or is something wrong with this, since it is referenced within mysql_query():
$Query = "INSERT INTO chatboard (UserName, IP, EMail, Message) values('$UserName', '$IP', '$EMail', '$Message')";

#4 LuciferStar

    Advanced Member

  • Kontributors
  • PipPipPipPipPipPipPip
  • 114 posts
  • Location:Suzhou Jiangsu China

Posted 22 January 2005 - 06:08 AM

TRY
<?php
$UserName = $_POST['UserName'];
$EMail = $_POST['EMail'];
$Message = $_POST['Message'];
$IP = $REMOTE_ADDR;
$Query = "INSERT INTO chatboard (UserName, IP, EMail, Message) values(".$UserName.", ".$IP.", ".$EMail.", ".$Message.")";
include "db_chat.php"; //Database connection file
mysql_query($Query);
mysql_close();
include "chat.php";
?>





Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users