When I use importer.php, it imports the links but doesn't pull in all fields.
With the following importer.php file and importlinks.txt file, it correctly pulls in the URL, email, cat id, and link type. However, it won't pull in the Title, Description, or Recip URL for any of the links.
In the importer.php config, I use a hard break for the $linksep.
$filename = 'importlinks.txt'; // put the name of the database file here
$linksep = ' '; // Please identify the unique character sequence which separates link entries in the file $fieldsep = '|'; // Please identify the unique character sequence which separates fields in each link
$titleloc = '0'; // The number, counding from left to right starting at ZERO of the term where the link title appears within each link line $urlloc = '1'; // # of the term where the link URL appears within each link line $descriploc = '2'; // # of the term where the link description appears within each link line $votesloc = ''; // # of the term where the link's total number of votes appears within each link line $sumofvotesloc = ''; // # of the term where the link's total number of vote values appears within each link line $ratingloc = ''; // # of the term where the link rating appears within each link line $reciploc = '3'; // # of the term where the link reciprocal URL appears within each link line $hitsoutloc = ''; // # of the term where the link hits out appears within each link line $hitsinloc = ''; // # of the term where the link hits in appears within each link line $catidloc = '4'; // # of the term where the link's category id number appears within each link line $emailloc = '5'; // # of the term where the email address of the link submitter appears within each link line $typeloc = '6'; // # of the term where the link type of this link appears within each link line
//$hardcodecategory = ''; // fill this in with a category id if you want to make all links be added to a particular category instead of specifying the category id for each link
/* End configuration section */
$thefile = fileread($filename);
$linkdata = explode($linksep, $thefile); $num = sizeof($linkdata); for ($x=0; $x<$num; $x++) { $linkline = explode($fieldsep, $linkdata[$x]); $thislink = new onelink('blank', 'blank'); $thislink->validated = 1; $thislink->hide = 'no'; $thislink->time = time(); if ($typeloc) $thislink->type = $linkline[$typeloc]; if (!$thislink->type) $thislink->type = 'regular'; if ($emailloc) $thislink->email = $linkline[$emailloc]; if ($titleloc) $thislink->title = $linkline[$titleloc]; if ($urlloc) $thislink->url = $linkline[$urlloc]; if ($hitsoutloc) $thislink->hits = $linkline[$hitsoutloc]; if ($hitsinloc) $thislink->hitsin = $linkline[$hitsinloc]; if ($ratingloc) $thislink->rating = $linkline[$ratingloc]; if ($votesloc) $thislink->votes = $linkline[$votesloc]; if ($sumofvotesloc) $thislink->sumofvotes = $linkline[$sumofvotesloc]; if ($recipurlloc) $thislink->recipurl = $linkline[$reciploc]; if ($descriptionloc) $thislink->description = $linkline[$descriploc]; if ($hardcodecategory) $thislink->catid = $hardcodecategory; else $thislink->catid = $linkline[$catidloc]; if ($thislink->catid < 1) die ("A bad category id (less than 1) was entered"); echo "Adding link <a href=". $thislink->url .">". $thislink->title ."</a> to category #". $thislink->catid ."... "; if (!(isduplicate($url, 'soft')) && ($settings->checkfordupdomain == 'no' || !(isduplicate($url, 'hard')))) $thislink->add();
} echo "<p>Done importing.</p>"; ?>
########### end importer.php #############
*********** begin importlinks.txt *********
Fred|http://www.yofred.com/|descrip of fred...|http://www.yofred.com/links.htm|4|fred@yofred.com|recip Ethel|http://www.yoethel.com/|descrip of ethel...||1|ethel@yoethel.com|regular
******** end importlinks.txt **************
Here's what I get in the browser when I call importer.php:
Adding link to category #4... Adding link to category #1... A bad category id (less than 1) was entered
Sorry....it's missing in the demo data in the thread, but it's in the real flatfile:
Fred |http://www.yofred.com/|descrip of fred... http://www.yofred.com/links.htm|4|fred@yofred.com|recip Ethel |http://www.yoethel.com/|descrip of ethel...||1|ethel@yoethel.com|regular
************
I just tried the real file again...with the separator in place....and I got the following message:
Adding link to category #26... Adding link to category #15... A bad category id (less than 1) was entered
The links were added as mentioned but only certain fields were imported, the others were skipped. Things are the same as first mentioned.
I just tried making the first line in the link file just a hard return and start the link data on the second line on down, but no luck.
I also added further fields to the flatfile and moved data to those fields because I noticed that it's importer.php seems to be skipping the same field numbers. It worked for one field, but not the others that I tried. (I also changed the field values in importer.php to point to the new locations). Why would it grab data from some fields but skip others?
Believe it or not, the importer.php capability was the main reason I purchased the script.
Got my fingers crossed that I can get this working. Any help is MOST appreciated
Fred |http://www.yofred.com/|descrip of fred... http://www.yofred.com/links.htm|4|fred@yofred.com|recip Ethel |http://www.yoethel.com/|descrip of ethel...||1|ethel@yoethel.com|regular
Now you've got two links on the same line (that being why I presumed in the post above that you only had 2 links, since there are two lines). If a line break is your separator, you have to use it between all links.
In my windows text editor (www.pspad.com), I show two lines:
Line 1:
Fred |http://www.yofred.com/|descrip of fred... |http://www.yofred.com/links.htm|4|fred@yofred.com|recip
Line 2:
Ethel |http://www.yoethel.com/|descrip of ethel...||1|ethel@yoethel.com|regular
...that results in this:
Fred |http://www.yofred.com/|descrip of fred... |http://www.yofred.com/links.htm|4|fred@yofred.com|recip Ethel |http://www.yoethel.com/|descrip of ethel...||1|ethel@yoethel.com|regular
I put each row of link data on its own line by simply hitting the Enter key once after each line (except the last line):
DATA FOR LINK 1 (click enter key here to start new line) DATA FOR LINK 2
then save...
In the importer.php config, I used the same "click enter key" once for the $linksep variable - a hard return:
$linksep = ' ';
What else should I be doing? I wish there were a full-blown example for users who create/edit using a windows text editor but who then upload the files to their linux website.
As mentioned in my emails, I'd be totally happy paying for a working solution. It would save me tons of lost time.
I'd be happy to pay you to put together a working example that matches my situation. Please let me know as soon as you can. I'd love to start putting your very nice link system to work, but I need the importer able to handle the following flatfile:
Site 1|http://www.mysite1.com/|descrip of Site 1|http://www.mysite1.com/links/|26|info@mysite1.com|recip Site 2|http://www.mysite2.com/|descrip of Site 2|http://www.mysite2.com/links/|14|info@mysite2.com|regular Site 3|http://www.mysite3.com/|descrip of Site 3|http://www.mysite3.com/resources/fred/|8|info@mysite3.com|recip Site 4|http://www.mysite4.com/|descrip of Site 4|http://www.mysite4.com/links/favorites/|17|info@mysite4.com|regular Site 5|http://www.mysite5.com/|descrip of Site 5|http://www.mysite5.com/links/|6|info@mysite5.com|recip Site 6|http://www.mysite6.com/|descrip of Site 6|http://www.mysite6.com/links/shopping/|13|info@mysite6.com|regular Site 7|http://www.mysite7.com/|descrip of Site 7|http://www.mysite7.com/links/|28|info@mysite7.com|recip Site 8|http://www.mysite8.com/|descrip of Site 8|http://www.mysite8.com/links/|7|links@mysite8.com|regular Site 9|http://www.mysite9.com/|descrip of Site 9|http://www.mysite9.com/links/|18|info@mysite9.com|recip Site 10|http://www.mysite10.com/|descrip of Site 10|http://www.mysite10.com/links/|3|info@mysite10.com|regular
I can't for the life of me get importer.php to work fully.
I just tried the following, but the result was the same - only certain fields were entered, the others ignored. I put all the link data all on one line but used [&] as the link separator and [|] as the field separator. The far end of the line ended with just the last field of the last link but no separator of any kind (not sure if this makes a difference)
It also doesn't watch out for duplicates (links that are already in the db) as far as I can tell.
In importlinks.txt:
Site 1[|]http://www.mysite1.com/[|]descrip of Site 1[|]http://www.mysite1.com/links/[|]26[|]info@mysite1.com[|]recip[&]Site 2[|]http://www.mysite2.com/[|]descrip of Site 2[|]http://www.mysite2.com/links/[|]14[|]info@mysite2.com[|]regular[&]Site 3[|]http://www.mysite3.com/[|]descrip of Site 3[|]http://www.mysite3.com/links/[|]8[|]info@mysite3.com[|]recip[&]Site 4[|]http://www.mysite4.com/[|]descrip of Site 4[|]http://www.mysite4.com/links/[|]17[|]info@mysite4.com[|]regular[&]Site 5[|]http://www.mysite5.com/[|]descrip of Site 5[|]http://www.mysite5.com/links/[|]6[|]info@mysite5.com[|]recip[&]Site 6[|]http://www.mysite6.com/[|]descrip of Site 6[|]http://www.mysite6.com/links/[|]13[|]info@mysite6.com[|]regular[&]Site 7[|]http://www.mysite7.com/[|]descrip of Site 7[|]http://www.mysite7.com/links/[|]28[|]info@mysite7.com[|]recip[&]Site 8[|]http://www.mysite8.com/[|]descrip of Site 8[|]http://www.mysite8.com/links/[|]7[|]info@mysite8.com[|]regular[&]Site 9[|]http://www.mysite9.com/[|]descrip of Site 9[|]http://www.mysite9.com/links/[|]18[|]info@mysite9.com[|]recip[&]Site 10[|]http://www.mysite10.com/[|]descrip of Site 10[|]http://www.mysite10.com/links/[|]3[|]info@mysite10.com[|]regular
In importer.php:
$linksep = '[&]'; // Please identify the unique character sequence which separates link entries in the file $fieldsep = '[|]'; // Please identify the unique character sequence which separates fields in each link
0/5
1
2
3
4
5
This thread is closed, so you cannot post a reply.
Comments on importer.php problem
Experienced
Usergroup: Customer
Joined: May 23, 2006
Total Topics: 16
Total Comments: 51
I snagged the latest version of importer.php.
When I use importer.php, it imports the links but doesn't pull in all fields.
With the following importer.php file and importlinks.txt file, it correctly pulls in the URL, email, cat id, and link type. However, it won't pull in the Title, Description, or Recip URL for any of the links.
In the importer.php config, I use a hard break for the $linksep.
########## begin importer.php ############
<?php
require 'start.php';
// Flat file database import script for WSN Links
// Place this file in the WSN Links directory
/* Configure this section to your needs */
$filename = 'importlinks.txt'; // put the name of the database file here
$linksep = '
'; // Please identify the unique character sequence which separates link entries in the file
$fieldsep = '|'; // Please identify the unique character sequence which separates fields in each link
$titleloc = '0'; // The number, counding from left to right starting at ZERO of the term where the link title appears within each link line
$urlloc = '1'; // # of the term where the link URL appears within each link line
$descriploc = '2'; // # of the term where the link description appears within each link line
$votesloc = ''; // # of the term where the link's total number of votes appears within each link line
$sumofvotesloc = ''; // # of the term where the link's total number of vote values appears within each link line
$ratingloc = ''; // # of the term where the link rating appears within each link line
$reciploc = '3'; // # of the term where the link reciprocal URL appears within each link line
$hitsoutloc = ''; // # of the term where the link hits out appears within each link line
$hitsinloc = ''; // # of the term where the link hits in appears within each link line
$catidloc = '4'; // # of the term where the link's category id number appears within each link line
$emailloc = '5'; // # of the term where the email address of the link submitter appears within each link line
$typeloc = '6'; // # of the term where the link type of this link appears within each link line
//$hardcodecategory = ''; // fill this in with a category id if you want to make all links be added to a particular category instead of specifying the category id for each link
/* End configuration section */
$thefile = fileread($filename);
$linkdata = explode($linksep, $thefile);
$num = sizeof($linkdata);
for ($x=0; $x<$num; $x++)
{
$linkline = explode($fieldsep, $linkdata[$x]);
$thislink = new onelink('blank', 'blank');
$thislink->validated = 1;
$thislink->hide = 'no';
$thislink->time = time();
if ($typeloc) $thislink->type = $linkline[$typeloc];
if (!$thislink->type) $thislink->type = 'regular';
if ($emailloc) $thislink->email = $linkline[$emailloc];
if ($titleloc) $thislink->title = $linkline[$titleloc];
if ($urlloc) $thislink->url = $linkline[$urlloc];
if ($hitsoutloc) $thislink->hits = $linkline[$hitsoutloc];
if ($hitsinloc) $thislink->hitsin = $linkline[$hitsinloc];
if ($ratingloc) $thislink->rating = $linkline[$ratingloc];
if ($votesloc) $thislink->votes = $linkline[$votesloc];
if ($sumofvotesloc) $thislink->sumofvotes = $linkline[$sumofvotesloc];
if ($recipurlloc) $thislink->recipurl = $linkline[$reciploc];
if ($descriptionloc) $thislink->description = $linkline[$descriploc];
if ($hardcodecategory) $thislink->catid = $hardcodecategory;
else $thislink->catid = $linkline[$catidloc];
if ($thislink->catid < 1) die ("A bad category id (less than 1) was entered");
echo "Adding link <a href=". $thislink->url .">". $thislink->title ."</a> to category #". $thislink->catid ."... ";
if (!(isduplicate($url, 'soft')) && ($settings->checkfordupdomain == 'no' || !(isduplicate($url, 'hard')))) $thislink->add();
}
echo "<p>Done importing.</p>";
?>
########### end importer.php #############
*********** begin importlinks.txt *********
Fred|http://www.yofred.com/|descrip of fred...|http://www.yofred.com/links.htm|4|fred@yofred.com|recip
Ethel|http://www.yoethel.com/|descrip of ethel...||1|ethel@yoethel.com|regular
******** end importlinks.txt **************
Here's what I get in the browser when I call importer.php:
Adding link to category #4... Adding link to category #1... A bad category id (less than 1) was entered
Any idea what could be wrong?
Many thanks for any thoughts
Experienced
Usergroup: Customer
Joined: May 23, 2006
Total Topics: 16
Total Comments: 51
Does anyone have any idea? I really need this to work. Thanks
developer
Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California
Total Topics: 61
Total Comments: 7868
Your data file doesn't have a seperator between title and URL.
Experienced
Usergroup: Customer
Joined: May 23, 2006
Total Topics: 16
Total Comments: 51
Sorry....it's missing in the demo data in the thread, but it's in the real flatfile:
Fred |http://www.yofred.com/|descrip of fred... http://www.yofred.com/links.htm|4|fred@yofred.com|recip
Ethel |http://www.yoethel.com/|descrip of ethel...||1|ethel@yoethel.com|regular
************
I just tried the real file again...with the separator in place....and I got the following message:
Adding link to category #26... Adding link to category #15... A bad category id (less than 1) was entered
The links were added as mentioned but only certain fields were imported, the others were skipped. Things are the same as first mentioned.
Experienced
Usergroup: Customer
Joined: May 23, 2006
Total Topics: 16
Total Comments: 51
DIFFERENT OS
Edited in Win but running in Linux - does this make a difference related to the hard break?
In the following thread:
www.webmastersite.net/forum...id=3010&highlight=importer
...you mentioned that a hard return for the linksep could just be like this:
$linksep = '
'; // Please identify the unique character sequence which separates link entries in the file
so long as it is edited and created on the same OS.
However, I edit in Windows but I run scripts in Linux.
So....now the question is how would you represent a hard return that is first edited in Win but intended to be run on Linux?
Thanks
Experienced
Usergroup: Customer
Joined: May 23, 2006
Total Topics: 16
Total Comments: 51
Another issue that I'm finding is that importer.php isn't really factoring in duplicate links.
I read somewhere that importer.php would not add a link if it found a dupe. Is that right?
However, at least with my mixed results above, the script will continue to add a domain even if dupes are in the db.
In wsn config:
"Check for duplicate URLs on submission? YES"
"Dissallow any reuse of the same domain name? YES"
Experienced
Usergroup: Customer
Joined: May 23, 2006
Total Topics: 16
Total Comments: 51
I just tried making the first line in the link file just a hard return and start the link data on the second line on down, but no luck.
I also added further fields to the flatfile and moved data to those fields because I noticed that it's importer.php seems to be skipping the same field numbers. It worked for one field, but not the others that I tried. (I also changed the field values in importer.php to point to the new locations). Why would it grab data from some fields but skip others?
Believe it or not, the importer.php capability was the main reason I purchased the script.
Got my fingers crossed that I can get this working. Any help is MOST appreciated
developer
Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California
Total Topics: 61
Total Comments: 7868
Since you only have two links in your data file, isn't that proper? The "bad category" message probably means you've got a trailing line break.
so long as it is edited and created on the same OS.
However, I edit in Windows but I run scripts in Linux.
That means you're editing and creating in Windows, presumably, unless you like to ssh into the server and edit the data file in vi.
developer
Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California
Total Topics: 61
Total Comments: 7868
Now you've got two links on the same line (that being why I presumed in the post above that you only had 2 links, since there are two lines). If a line break is your separator, you have to use it between all links.
Experienced
Usergroup: Customer
Joined: May 23, 2006
Total Topics: 16
Total Comments: 51
Hi Paul
I don't understand what I'm missing.
In my windows text editor (www.pspad.com), I show two lines:
Line 1:
Line 2:
...that results in this:
I put each row of link data on its own line by simply hitting the Enter key once after each line (except the last line):
DATA FOR LINK 1 (click enter key here to start new line)
DATA FOR LINK 2
then save...
In the importer.php config, I used the same "click enter key" once for the $linksep variable - a hard return:
$linksep = '
';
What else should I be doing? I wish there were a full-blown example for users who create/edit using a windows text editor but who then upload the files to their linux website.
As mentioned in my emails, I'd be totally happy paying for a working solution. It would save me tons of lost time.
I'd be happy to pay you to put together a working example that matches my situation. Please let me know as soon as you can. I'd love to start putting your very nice link system to work, but I need the importer able to handle the following flatfile:
Please let me know. Many thanks, Paul
Experienced
Usergroup: Customer
Joined: May 23, 2006
Total Topics: 16
Total Comments: 51
Hi, 'gin, Paul
I'd rather pay you the money to get this working asap than continue experimenting cuz I'm losing too much time.
Please let me know.
Thanks
Experienced
Usergroup: Customer
Joined: May 23, 2006
Total Topics: 16
Total Comments: 51
I can't for the life of me get importer.php to work fully.
I just tried the following, but the result was the same - only certain fields were entered, the others ignored. I put all the link data all on one line but used [&] as the link separator and [|] as the field separator. The far end of the line ended with just the last field of the last link but no separator of any kind (not sure if this makes a difference)
It also doesn't watch out for duplicates (links that are already in the db) as far as I can tell.
In importlinks.txt:
In importer.php: