LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-22-2011, 04:17 PM   #1
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 431
Blog Entries: 32

Rep: Reputation: 3
sqlite query change question marks to NULL (?)


Hi, I got the query insertion and everything correctly:
Code:
		$db = DBI->connect("DBI:SQLite2:dbname=/var/db/blog1.db");
		$read = $db->prepare("SELECT * FROM blog WHERE id='$id'");
		$read->execute();
		@rows = $read->fetchrow();
		if ((scalar(@rows) == 0) && ($id ne "") && ($til ne "") && ($descrip ne "") && ($pubDate[$i] ne "") && ($link[$i] ne "")) {
			$db->do("INSERT INTO blog (id, title, content, datetime, link) values (\"$id\", \"$til\", \"$descrip\", \"$pubDate[$i]\", \"$link[$i]\")");
}
This is the actual query, for everywhere there are question marks for eg:
This is my content?
Changes to:
This is my contentNULL

I also tried the query with:
"INSERT INTO blog (id, title, content, datetime, link) values (\"?\", \"?\", ?, \"?\", ?)"
for 1,2,4 the result is NULL, for 3,5 the result is empty (nothing was inserted into the table.
Thanks,
Ted
 
Old 04-22-2011, 05:48 PM   #2
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Check how your columns are defined. For example, are you trying to insert a question mark into an integer field?
 
Old 04-22-2011, 08:07 PM   #3
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 431

Original Poster
Blog Entries: 32

Rep: Reputation: 3
Hi, the type are as follow:

id INTEGER 0 Edit Delete Index Unique
title VARCHAR(150) 0 Edit Delete Index Unique
tags VARCHAR(200) 0 Edit Delete Index Unique
content TEXT 0 Edit Delete Index Unique
datetime TIMESTAMP 0 Edit Delete Index Unique
link VARCHAR(400) 0 Edit Delete Index Unique


I found something interesting thing:
only certain row actually have NULL, but they are inserted exactly the same loop :/

blog.php?user=ted_chou12&id=60
blog.phpNULLuser=ted_chou12&id=52
blog.phpNULLuser=ted_chou12&id=51
blog.phpNULLuser=ted_chou12&id=49
blog.php?user=ted_chou12&id=48
blog.phpNULLuser=ted_chou12&id=47
blog.phpNULLuser=ted_chou12&id=46
blog.php?user=ted_chou12&id=45
blog.phpNULLuser=ted_chou12&id=44
blog.phpNULLuser=ted_chou12&id=43
blog.php?user=ted_chou12&id=42
blog.phpNULLuser=ted_chou12&id=41
blog.phpNULLuser=ted_chou12&id=40
blog.php?user=ted_chou12&id=39
blog.php?user=ted_chou12&id=38
blog.php?user=ted_chou12&id=37
blog.phpNULLuser=ted_chou12&id=36
blog.phpNULLuser=ted_chou12&id=35
blog.php?user=ted_chou12&id=34
blog.phpNULLuser=ted_chou12&id=33
blog.phpNULLuser=ted_chou12&id=32
blog.php?user=ted_chou12&id=31
blog.php?user=ted_chou12&id=30
blog.phpNULLuser=ted_chou12&id=29

Last edited by ted_chou12; 04-22-2011 at 08:09 PM.
 
Old 04-25-2011, 02:36 AM   #4
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 431

Original Poster
Blog Entries: 32

Rep: Reputation: 3
Hi, does anyone has any ideas? I have searched online and found one thread related so far, but it doesn't have solution.
Thanks,
Ted
 
Old 04-25-2011, 05:36 AM   #5
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Hi

Read this guide:

http://www.perl.com/pub/1999/10/DBI.html

In particular the last section "Don't do this". That's what your script is doing. Use ? for parameters in your SQL query and pass the parameters to the execute call.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Sqlite-Commander - A ncurses based tool to display the records and tables of a sqlite database LXer Syndicated Linux News 0 01-02-2011 08:11 AM
help with sqlite query to retriev browser history tiggertie Linux - General 1 05-24-2010 07:05 PM
Using question marks in mod_rewrite kevin-fdc Linux - Server 4 03-16-2010 04:24 PM
question marks show when doing ll abylin1 Linux - Newbie 9 01-15-2008 02:54 PM
Quotes as Question Marks in Thunderbird. Matir Linux - Software 2 07-11-2005 02:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration