• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Active Record is producing wrong SQL. Please help

#1
[eluser]FutureKing[/eluser]
Hi,
I am trying to make a RSS2.0 feed reader with code igniter. This app will to the following task:
1. Downloading RSS2.0 feed from URL
2. Insert everything in MySQL Database.

for second step I am using Active Record Insert But I am getting following error:
Code:
A Database Error Occurred
Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'News, http://news.google.com/, Google News, Fri, 08 May 2009 07:48:16 GMT, 'http' at line 1

INSERT INTO `feed_urls` (`f_title`, `f_link`, `f_desc`, `f_date`, `f_url`) VALUES (Google News, http://news.google.com/, Google News, Fri, 08 May 2009 07:48:16 GMT, 'http://news.google.com/?output=rss')

I am using SimpleXmlElement for Downloading feeds.(see tutorial: http://nettuts.com/javascript-ajax/how-t...creencast/)
Why there is no inverted comma on my SQL query?

#2
[eluser]xwero[/eluser]
What is your AR code? The problem with your sql statement is that none of the text values, except the f_url are surrounded by single quotes.

#3
[eluser]jdfwarrior[/eluser]
[quote author="xwero" date="1241787596"]What is your AR code? The problem with your sql statement is that none of the text values, except the f_url are surrounded by single quotes.[/quote]

What he said. And that's something that's done automatically so... yeah, feed us the code please.

#4
[eluser]FutureKing[/eluser]
Hi, My problem solved! I converted everything to string by the following code:
Code:
settype($title, "string");
settype($link, "string");
settype($desc, "string");
settype($date, "string");
and the sql statement started to generate quotes in code.

#5
[eluser]Unknown[/eluser]
I just faced this problem and sorted it in a similar manner, but I want to know why this is a problem in the first place. When generating the query, can't AR do a gettype() and then decide to put quotes or not?

The funny thing is that I just finished one project that had mixed data types and I never got any error. Why did I get it with this project?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.