Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3282926
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:58:58+00:00 2026-05-17T19:58:58+00:00

I am trying to create a php script that inputs the HTTP links pasted

  • 0

I am trying to create a php script that inputs the HTTP links pasted into a textarea into a separated row in a database. More exactly:

First page is where the textarea (name=textarea-linkfield) is, links are going to be pasted here

http://www.stackoverflow.com
http://www.yahoo.com
....
http://google.com

The links are being carried over into the php script with $linkfield=$_POST['textarea-linkfield']; and I would like the links to be inserted into the database, each http link per row. Database name: site, table name plow, columns: id, url, …

L.E. I tried just as proof of concept:

$linkfield=$_POST['textarea-linkfield'];
$strip=explode("\n",$linkfield);
echo $strip[1];

but I get 500 INTERNAL SERVER ERROR

L.E.2

The answer:

// Split the string into pieces
$pieces = explode("\n", str_replace(array("\n", "\r\n"), "\n", trim($linkfield)));

// Build the top of the INSERT query
$sql = "INSERT INTO `plow`(`url`) VALUES\n";

// Build the rest of the ;INSERT query by re-assembling the
// pieces.
$sql .= "('";
$sql .= implode("'), ('", $pieces);
$sql .= "')"; 
mysql_query($sql) or die ('Error: ' . mysql_error());

mysql_close();

Thanks to all for their help.
Chris.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:59:00+00:00Added an answer on May 17, 2026 at 7:59 pm

    Depending on your os a newline can be “\n”, “\r\n” or “\r”.

    Give this a shot:

    $strip=explode("<br>", nl2br($linkfield));
    

    or maybe safer:

    $strip=explode("\n", str_replace(array("\n", "\r\n"), "\n", $linkfield));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a newbie in php and Wordpress. I'm trying to create a script that
I am trying to write a PHP script that will create an HTML form
I am trying to create a php script that will retrieve the WOW factor
I am trying to create a little php script that can make my life
I'm currently trying to create a php script were the user has the ability
Here's an idea. I'm trying to create file from PHP script. File may be
i'm trying to create nodes and taxonomy terms through a custom php script by
I am trying to create a php file that adds a user and create
I am trying to create a php file that would scan a directory, make
I'm trying to create a PHP form on a website that collects users' name,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.