Jump to content

[SOLVED] mysql insert problem


Kingy

Recommended Posts

This is a weird error that i have no idea how to fix.

 

I have a php script that connects to an irc server gets the room list and i then have it inserting it into a mysql database.

 

It works well and once it retrieves the roomlist it echo's every single room name. But when it inserts them into the database it only inserts half the rooms.

 

eg: it will echo #Lobby, #Help, #Room1, #Room2, #Room3, #Room4

 

and it will only insert. #Lobby, #Help, #Room1

 

any ideas?

Link to comment
Share on other sites

case 322:

 

$chan = explode(' ', $data, 7);

 

$channel = $chan[3];

$users = $chan[4];

$topic = $chan[6];

 

echo "CHANNEL: $channel";

echo "USERS: $users";

echo "TOPIC $topic";

 

mysql_query("INSERT INTO rooms (channel, users, topic) VALUES ('$channel', '$users', '$topic')");

break;

Link to comment
Share on other sites

Try escaping the string it might contain a quote or other illegal character

<?php
case 322:

$chan = explode(' ', $data, 7);

$channel = mysql_real_escape_strng($chan[3]);
$users = mysql_real_escape_strng($chan[4]);
$topic = mysql_real_escape_strng($chan[6]);

echo "CHANNEL: $channel";
echo "USERS: $users";
echo "TOPIC $topic";

mysql_query("INSERT INTO rooms (channel, users, topic) VALUES ('$channel', '$users', '$topic')");
break;
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.