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

  • Home
  • SEARCH
  • 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 385241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:27:38+00:00 2026-05-12T15:27:38+00:00

As you will see I am fetching the column, and trying to update column

  • 0

As you will see I am fetching the column, and trying to update column with new data.
$result2 line is my problem, I don’t think I can add $row[0] in there. How do I do it?

$result = mysql_query("SELECT link FROM items LIMIT 3");

while($row = mysql_fetch_array($result))

    {

    $url=($row[0]);

$rez2 = get_final_url($url);

$result2 = mysql_query("UPDATE items SET link = $rez2 WHERE id = $row[0] LIMIT 1")

or die(mysql_error()); 
  • 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-12T15:27:38+00:00Added an answer on May 12, 2026 at 3:27 pm

    You should use quotes:

    mysql_query("UPDATE items SET link = '{$res2}' WHERE id = $row[0]");
    

    And it would be ideal to use mysql_escape_string() function.

    So:

    $rez2 = mysql_escape_string(get_final_url($url));
    

    Also you’re trying to use $row[0] as link and as id. Most likely you want $row[0] element to be an ID, and something like $row[n] where n > 0 to be a link. But if you still want to use link you should query in the following manner:

    $result2 = mysql_query("UPDATE items SET link = '$res2' WHERE link = {$row[0]}");
    

    And do not forget to escape $row

    It is a good idea to use mysql_fetch_assoc() function – in this case you’ll get an associative array, so you’ll be able access elements by sql column names. And as result you could do something like:

    $result = mysql_query("SELECT id, link FROM items LIMIT 3");
    
    while($row = mysql_fetch_assoc($result))
    
    {
    
       $url=($row['link']);
    
       $rez2 = mysql_escape_string(get_final_url($url));
    
       $result2 = mysql_query("UPDATE items SET link = '{$res2}' WHERE id = {$row['id']}")
    
       or die(mysql_error());
    }
    

    Also if ID is a primary key you do not need LIMIT 1 in the update query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a mysqli data fetching problem. I will try to explain my problem
I am very new to C++ programming and you will see why. I want
Ok so as you all will see I am very new to this and
I am writing some code to update an application by fetching new dlls from
I will see if I can explain this clearly enough. I have 2 web
I'm trying to write a robot that will be fetching html parsing it daily.
If you go to http://moederdagontbijtplacemat.nl/ you will see a progress bar. The application is
When you open up the page while it's loading you will see menu coming
It might be a long shot posting this question here but we will see.
If you go to http://www.wilwaldon.com/learning/inner4a.html with IE7 you will see the middle 2 columns

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.