GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 19-Sep-2002, 19:50
pcxgamer's Avatar
pcxgamer pcxgamer is offline
Senior Member
 
Join Date: Sep 2002
Location: South Carolina, USA
Posts: 1,095
pcxgamer is a jewel in the roughpcxgamer is a jewel in the roughpcxgamer is a jewel in the rough
Exclamation

Little Help please


I have been working on a script for few days now and I can't seem to get it right, I have a simple txt based database file. I found a script that I use sometime back that adds edits and delete entries in the file. The problem I'm having is that the txt file needs the file written a certain way to be read by another script.

EX.

What the file needs to look like for the other script to work

Text|text|http://www.text.com||#text#|

But the script keeps writing it this way

Text|text|http://www.text.com|text|

I'm not sure how to get the script to write it the right way.

Thank you in advance any help that anyone can offer me.
Attached Files
File Type: zip database.zip (3.6 KB, 12 views)
  #2  
Old 20-Sep-2002, 03:58
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
the last time i looked at perl scripts, I was still hosted at Tripod; so I apologise if this doesn't help...

if i were u, i'd look for the line where it adds the data into your database.txt file.

I looked and found this line that i think is that line (which i modified for clarity / brevity) in edit.cgi:
Code:
print DATABASE1 "$input{'col_1'}|$input{'col_2'}|$input{'col_3'}|$input{'col_4'}\n";

i would try...
Code:
print DATABASE1 "$input{'col_1'}|$input{'col_2'}|$input{'col_3'}|#$input{'col_4'}#\n";

let me know if my guess was right?
  #3  
Old 20-Sep-2002, 05:39
pcxgamer's Avatar
pcxgamer pcxgamer is offline
Senior Member
 
Join Date: Sep 2002
Location: South Carolina, USA
Posts: 1,095
pcxgamer is a jewel in the roughpcxgamer is a jewel in the roughpcxgamer is a jewel in the rough
Thumbs up

The code you posted really help me out. It added the || | to the data.txt file. I worked with the script for a little bit but I think the reason that it wouldn't add the #personal# I think and I may be wrong but the # is the comment tag for perl. But I edited the edit_record.cgi and added a drop down menu to the form and put the #personal# in there and it works.

Thank you ever much for your help

I also needed to know if you would know ever I could get a web besed editor for my site. I downloaded CSCreate script from cgiscript.net. But it doesn't seem to be working I'm going to work with it for a few more days. But I may need a little help with it.


But thanks greatly for the help..

Later
  #4  
Old 20-Sep-2002, 06:30
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
ofcourse, how silly of me :

try
Code:
print DATABASE1 " $input{'col_1'}|$input{'col_2'}|$input{'col_3'}|\#$input{'col_4'}\#\n";

the backslash is for 'escaping' any special characters like the #
  #5  
Old 20-Sep-2002, 07:54
pcxgamer's Avatar
pcxgamer pcxgamer is offline
Senior Member
 
Join Date: Sep 2002
Location: South Carolina, USA
Posts: 1,095
pcxgamer is a jewel in the roughpcxgamer is a jewel in the roughpcxgamer is a jewel in the rough
Thumbs up

ok I edited the file again and its right, The last problem is that if I edit one entry in data.txt it erase the format of the other entry.

EX Before I edit.....

test|test|www.test.com||#personal#|
test|test|www.test.com||#personal#|
test|test|www.test.com||#personal#|


after i edit one entry.....

test|test|www.test.com||#personal#|
test|test|www.test.com||##|
test|test|www.test.com||##|

I think it may be in the view.cgi file somewhere. because when I edit the data.txt using the script the last entry is always blank

Any ideas?

Thanks

I uploaded the file I've been working with.
Attached Files
File Type: zip edit.zip (2.8 KB, 6 views)
  #6  
Old 21-Sep-2002, 06:09
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
without having looked at the file yet, how does the script know which record to edit if there's no unique id for each line of record?
  #7  
Old 21-Sep-2002, 06:34
pcxgamer's Avatar
pcxgamer pcxgamer is offline
Senior Member
 
Join Date: Sep 2002
Location: South Carolina, USA
Posts: 1,095
pcxgamer is a jewel in the roughpcxgamer is a jewel in the roughpcxgamer is a jewel in the rough
I'm not really sure. I've been looking at the script last night and this morning. I'll look into it and see. This is a little different from the last time I use this script I'll I had to do was change the Fields and a small edit here and there but I never tried to add a field. But I'll play around with it to day and I'll see if I can found out.

Thank you for the help.
  #8  
Old 21-Sep-2002, 07:14
pcxgamer's Avatar
pcxgamer pcxgamer is offline
Senior Member
 
Join Date: Sep 2002
Location: South Carolina, USA
Posts: 1,095
pcxgamer is a jewel in the roughpcxgamer is a jewel in the roughpcxgamer is a jewel in the rough
ok I think that I may have found the problem. in the edit.cgi script on the line

Code:
print DATABASE "$first | $last | $email || \#$cat\# |\n";

ok to explain the $cat is the var that I gave the 4th field in the script but I think the problem lies in the database.txt file I don't think it can read the 4th field. it I exe the script with the above line that when it erases the 4th field but if I change the code to

Code:
print DATABASE "$first | $last | $email || \#Personal\# |\n";

it still will not work but it will write personal in the 4th field on all but the one I edit.

I hope this make sence I'm not very good and explaining it.
  #9  
Old 21-Sep-2002, 07:26
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
in php if i had to do something like that, it would be

PHP Code:

print DATABASE "$first | $last | $email ||\\#".$cat."\\# |\n"; 


or
PHP Code:

print DATABASE "$first | $last | $email || \\#{$cat}\\# |\n"; 



hope u see what i am trying to say here
  #10  
Old 21-Sep-2002, 07:45
pcxgamer's Avatar
pcxgamer pcxgamer is offline
Senior Member
 
Join Date: Sep 2002
Location: South Carolina, USA
Posts: 1,095
pcxgamer is a jewel in the roughpcxgamer is a jewel in the roughpcxgamer is a jewel in the rough
Ok I'm getting closer I know that the reason it will not display it is in the view.cgi file in this line maybe I've been playing with it but no luck yet.

Code:
foreach $rec (@ODB){ chomp($rec); ($first,$last,$email,$cat)=split(/\|/,$rec);
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 14:47.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.