ludjer Posted June 5, 2007 Share Posted June 5, 2007 i am trying to insert some info into a mysql database but it just wont work <?php include "lastRSS.php"; function connect() { $username="root"; $password=""; $database="rssreader"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); } function rsstosql($url,$table) { connect(); $rss = new lastRSS; $rss->cache_dir = './temp'; $rss->cache_time = 1200; if ($rs = $rss->get($url)) { $time; foreach($rs['items'] as $item) { if ($item['description']==null) { $time = $item['title']; }else{ $title = substr($item['title'],2); $desc = $item['description']; $sql = "INSERT INTO `$table` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, $time, $title, $desc, null)"; echo $sql."<br>"; mysql_query($sql); } } } else { die("Error: It's not possible to reach RSS file...\n"); } mysql_close(); } rsstosql('http://www.tvrage.com/myrss.php',"showstoday"); ?> also this is what the SQL query's say INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 08:00 pm, Deal Or No Deal (US) (02x68), Episode 107, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 08:00 pm, On the Lot (01x05), 1 of 15 Directors Voted Off, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 09:00 pm, Deadliest Catch (03x10), Trials of the Greenhorns, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 09:00 pm, Punk'd (S08-Special), Punk'd Awards, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 09:00 pm, America's Got Talent (02x01), Episode 201, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 09:00 pm, The Universe (01x02), Mars: The Red Planet, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 09:00 pm, ALMA Awards (01x07), 2007 ALMA Awards, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 09:00 pm, Decorating Cents (01x01), Decorating Cents Dream Wedding, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 09:30 pm, Dog the Bounty Hunter (04x13), Fly Boy, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 09:30 pm, Scarred (01x09), Season 1, Episode 9, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 10:00 pm, Kathy Griffin: My Life on the D-List (03x01), Season Opener, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 10:00 pm, The Real World/Road Rules Challenge (14x11), Pane In The Glass, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 10:00 pm, The Shield (06x10), Spanish Practices, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 10:00 pm, Criss Angel: Mindfreak (03x01), Luxor Light, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 10:00 pm, Secret Lives Of Women (03x05), Lipstick Lesbians, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 10:00 pm, America's Got Talent (02x02), Episode 202, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 10:00 pm, ECW on Sci Fi (02x23), June 5, 2007, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 10:00 pm, Whose Wedding Is It Anyway? (US) (06x08), Now You May Kiss the...Groom?, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 10:00 pm, Jon & Kate Plus 8 (01x08), Shopping for Ten, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 10:00 pm, After The Catch (01x02), Man vs. Nature, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 10:30 pm, Rob & Big (02x03), Season 2, Episode 3, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 10:30 pm, Spice Up My Kitchen (01x01), Kitchen Needs to Get Current, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 10:30 pm, Hollyoaks (12x181), Student Balls, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 11:00 pm, The Daily Show (12x74), Paul Rudd, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 11:00 pm, The Springer Hustle (01x08), Season 1, Episode 8, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 11:30 pm, The Colbert Report (03x74), Jessica Valenti, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 11:35 pm, Late Show with David Letterman (14x156), Chevy Chase, Amanda Beard, Satellite Party, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 11:35 pm, The Tonight Show with Jay Leno (15x166), George Clooney, senior-citizen band the Zimmers, Rihanna, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 12:35 am, Late Night with Conan O'Brien (14x148), Brian Williams, Leslie Mann, Los Straitjackets with Big Sandy, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 12:35 am, The Late Late Show with Craig Ferguson (03x90), Rosie Perez, David Milch, Patti Smith, null) INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, 01:35 am, Last Call with Carson Daly (06x66), Andy Richter, Gary Jules, null) thx in advance Link to comment https://forums.phpfreaks.com/topic/54352-solved-mysql-php-insert-not-working/ Share on other sites More sharing options...
per1os Posted June 5, 2007 Share Posted June 5, 2007 You don't have single quotes around the inserted data. $sql = "INSERT INTO `$table` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, '$time', '".mysql_real_escape_string($title)."', '".mysql_real_escape_string($desc)."', null)"; Try that. Link to comment https://forums.phpfreaks.com/topic/54352-solved-mysql-php-insert-not-working/#findComment-268771 Share on other sites More sharing options...
ludjer Posted June 5, 2007 Author Share Posted June 5, 2007 i tried it but it is still not working Link to comment https://forums.phpfreaks.com/topic/54352-solved-mysql-php-insert-not-working/#findComment-268773 Share on other sites More sharing options...
thefortrees Posted June 5, 2007 Share Posted June 5, 2007 single quotes! single quotes! Link to comment https://forums.phpfreaks.com/topic/54352-solved-mysql-php-insert-not-working/#findComment-268775 Share on other sites More sharing options...
thefortrees Posted June 5, 2007 Share Posted June 5, 2007 try removing the single quotes from around $table Link to comment https://forums.phpfreaks.com/topic/54352-solved-mysql-php-insert-not-working/#findComment-268777 Share on other sites More sharing options...
per1os Posted June 5, 2007 Share Posted June 5, 2007 Change this: mysql_query($sql); to this and report the error mysql_query($sql) or DIE(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/54352-solved-mysql-php-insert-not-working/#findComment-268778 Share on other sites More sharing options...
per1os Posted June 5, 2007 Share Posted June 5, 2007 try removing the single quotes from around $table Those are backticks around the table and column names, not single quotes. The problem lies else where. Link to comment https://forums.phpfreaks.com/topic/54352-solved-mysql-php-insert-not-working/#findComment-268779 Share on other sites More sharing options...
ludjer Posted June 5, 2007 Author Share Posted June 5, 2007 omw i think im going to shoot myself INSERT INTO `showstoday` (`ID`, `time`, `name`, `title`, `link`) VALUES (NULL, '08:00 pm', 'Deal Or No Deal (US) (02x68)', 'Episode 107', null) Column 'link' cannot be null im going to edit the database and then ill come back Link to comment https://forums.phpfreaks.com/topic/54352-solved-mysql-php-insert-not-working/#findComment-268783 Share on other sites More sharing options...
per1os Posted June 5, 2007 Share Posted June 5, 2007 debugging statements are lovely aren't they? Link to comment https://forums.phpfreaks.com/topic/54352-solved-mysql-php-insert-not-working/#findComment-268786 Share on other sites More sharing options...
ludjer Posted June 5, 2007 Author Share Posted June 5, 2007 i need to learn more php. anyway thx all that helped Link to comment https://forums.phpfreaks.com/topic/54352-solved-mysql-php-insert-not-working/#findComment-268788 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.