Jump to content


Photo

Updating a list field


  • Please log in to reply
4 replies to this topic

#1 Guardian2006

Guardian2006
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 16 September 2006 - 10:45 PM

I have searched the forums but have not found anything specific which relates to my problem.
I am fairly new to PHP/mySQL but have managed to get pretty far into the development of a script for stopping spam but now I'm stumped.

Although my script has its own tables, I need to update another table which has a 'list' field already populated with data.
My attempts so far have removed the existing data instead of appending the new data to the bottom of the list.

Assuming the table is named 'blocked' and the field is name 'refer' could anyone help me out?
I'm using a php form to set the post vars but I'm guessing I need to retrieve the data in the list field, put it into an array, append my data to the array and then do the field update but having an idea of what to do and actually doing it has me stumped.
Oh, the data is a list of domains in the format 'domainname.com'

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 16 September 2006 - 11:27 PM

Why are you appending to a "list" field?  Sounds like you should have multiple records.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 Guardian2006

Guardian2006
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 17 September 2006 - 12:10 AM

Thanks for taking the time to reply - seems I have made a mistake in my assumption of the field type.
The field NAME is 'list' whilst the field TYPE is actually 'longtext'.
I'm not able to change this structure as it belongs to a third party script that is designed to detect hacking attempts in a content management system and would break it.
The author is using this field to store a list of bannen domains (seperated by carriage returns) - the view for the field in phpmyadmin shows something like this

121hr.com
1st-call.net
1stcool.com
5000n.com
69-xxx.com
9irl.com
9uy.com
a-day-at-the-party.com
accessthepeace.com

and I just cannot figure out how to add additional domains to this list with them all being contained within the one field.
My own script is designed to detect bad referers and I thought I may as well incorporate the two by adding bad referer domains to this other table as an added way to block the domain from accessing the site.


#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 17 September 2006 - 02:44 PM

I see... well, you just need to CONCAT() the new domain on.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 Guardian2006

Guardian2006
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 18 September 2006 - 02:06 PM

I really appreciate you taking the time out to respond. I have to apologise for my lateness in replying as I was obsrobed by the issue at hand.
Thanks a bunch, that is exactly what I needed and I have used it to resolve my problem.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users