Kingy Posted November 11, 2007 Share Posted November 11, 2007 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? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 11, 2007 Share Posted November 11, 2007 code please? Quote Link to comment Share on other sites More sharing options...
Kingy Posted November 11, 2007 Author Share Posted November 11, 2007 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; Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 11, 2007 Share Posted November 11, 2007 <?php mysql_query("INSERT INTO rooms (channel, users, topic) VALUES ($channel, $users, $topic)"); ?> or <?php mysql_query('INSERT INTO rooms (channel, users, topic) VALUES ('.$channel.', '.$users.', '.$topic.')'); ?> Quote Link to comment Share on other sites More sharing options...
Kingy Posted November 11, 2007 Author Share Posted November 11, 2007 ok so i took the ' ' off the $channel, $users, $topic etc and now it doesnt insert anything at all? and same result for the '. .' - nothing Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted November 11, 2007 Share Posted November 11, 2007 try the second method Quote Link to comment Share on other sites More sharing options...
Kingy Posted November 11, 2007 Author Share Posted November 11, 2007 lol we keep missing each others edits... that bit didnt work either Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 11, 2007 Share Posted November 11, 2007 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; ?> Quote Link to comment Share on other sites More sharing options...
Kingy Posted November 11, 2007 Author Share Posted November 11, 2007 good idea, but it still not working Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 11, 2007 Share Posted November 11, 2007 is the field in your table big enough to hold all the data? Maybe use a tinytext or text field. Edit: I meant tinytext not smalltext. There is no such thing as smalltext fields Quote Link to comment Share on other sites More sharing options...
Kingy Posted November 11, 2007 Author Share Posted November 11, 2007 Daukan.. you are a legend lol. That was the problem. I had varchar(255) and some of the topics were very long lol. Changed it to a TEXT field. Thanks heaps. Quote Link to comment Share on other sites More sharing options...
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.