The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 23, 2012, 07:47:49 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Using Each url only once  (Read 800 times)
Keebler
Rookie
**
Offline Offline

Posts: 18


View Profile
« on: August 13, 2009, 12:27:53 AM »

This is going to be confusing.

I have a table with urls. I am trying to build a spider that will only use each url once, because when I load new urls into it, I dont want it to start all over again scraping the old urls once again.

How can I set up the table, so that when the spider queries the table for a new url, it only gets new urls?

I was thinking of setting it up something like, where along with the URL value, for unspidered urls I have a value that is automatically 0, and then once the URL has been used I switch the value to a 1. Then my query would have to be something that searches for URLS where value = 0?

my first query attempt was:

SELECT * FROM $dbUrltable LIMIT 1 WHERE create = 0

but it said that my syntax was wrong... I tried all sorts of variations but I cant figure it out.

Is my question understandable?

Basically, either how do I fix that query, or whats the best way of going about this.

Thanks in advance.
« Last Edit: August 13, 2009, 12:29:27 AM by Keebler » Logged

No links in signatures please
deregular
Expert
****
Offline Offline

Posts: 172


View Profile
« Reply #1 on: August 13, 2009, 04:57:23 AM »

Thats exactly how i would do it..

Try this instead..

SELECT * FROM $dbUrltable WHERE create = 0 LIMIT 1

Logged
Keebler
Rookie
**
Offline Offline

Posts: 18


View Profile
« Reply #2 on: August 16, 2009, 03:05:56 PM »

Thanks for the reply, sorry it took so long to get back. This is what happens when I use that code that you just showed:

Quote
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 'create = 0 LIMIT 1' at line 1
Logged

No links in signatures please
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #3 on: August 16, 2009, 03:28:11 PM »

Is create an int or string (like varchar)
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
Keebler
Rookie
**
Offline Offline

Posts: 18


View Profile
« Reply #4 on: August 16, 2009, 03:31:04 PM »

its an integer, default value of 0. but...

it worked when I added lil ` around the "create" column

like this

Code:
        $query = "SELECT * FROM $dbUrltable WHERE `create` = 0 LIMIT 1";

instead of

Code:
        $query = "SELECT * FROM $dbUrltable WHERE create = 0 LIMIT 1";
Logged

No links in signatures please
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #5 on: August 16, 2009, 03:49:24 PM »

Oh haha lol. Duh. Create is a reserved word. Forgot that. So yep the backqoutes fix that.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
Keebler
Rookie
**
Offline Offline

Posts: 18


View Profile
« Reply #6 on: August 16, 2009, 08:42:25 PM »

Oh haha lol. Duh. Create is a reserved word. Forgot that. So yep the backqoutes fix that.

OH thats why? That makes sense. hahaha.

I was wondering why I had never needed backquotes before.... I guess I should just rename the column name.
Logged

No links in signatures please
deregular
Expert
****
Offline Offline

Posts: 172


View Profile
« Reply #7 on: August 17, 2009, 01:27:33 AM »

Dammit, should have picked that up myself...  D'oh!
Logged
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #8 on: August 17, 2009, 08:27:17 AM »

its probably not something i would normally recognize because my column naming convention would never end up with a reserved word as the column. Probably similar for you.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!