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 8651525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:05:39+00:00 2026-06-12T14:05:39+00:00

I have a number of textareas, each with a unique assigned name (name=adcode$ID, for

  • 0

I have a number of textareas, each with a unique assigned name (name=”adcode$ID”, for example). When I try to pass those names to the code below, it doesn’t work because of the dynamic part.

if (isset($_POST['editadapp'])) {  // Edit AD
$newadcode = mysql_real_escape_string($_POST['.adcode$ID.']);
$doedit = "UPDATE ads SET adcode = '".$newadcode."') WHERE ads_ID=$ID" or die(mysql_error());
$updatead = mysql_query($doedit) or die(mysql_error());
    header("Location: " . $_SERVER['PHP_SELF']);

How can I resolve this?

  • 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-06-12T14:05:40+00:00Added an answer on June 12, 2026 at 2:05 pm

    There is so much wrong with this that it’s frightening.

    Firstly,

    $doedit = "UPDATE ads SET adcode = '".$newadcode."') WHERE ads_ID=$ID" or die(mysql_error());
    

    That code snippet is wrong on many levels.

    1. The sql syntax is wrong
    2. The sql is formatted with strings from user input (see parameterization of queries here
    3. or die() should not be used here, you’re creating a string

    Ideally you should have code like:

    $dbh =  new PDO('connectionstring to connect to your database');
    $sql = 'update ads set adcode = ? where ads_id = ?';
    $sth = $dbh->prepare($sql);
    $sth->execute(array($_POST['adcode' . $ID], $ID));
    

    Other topics:

    Are Paramerterized queries necessary in pdo?

    prepared queries with pdo

    Preventing sql injection in php

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

Sidebar

Related Questions

I have a number of textareas like this... <textarea name=a[] id=a[]></textarea> <textarea name=a[] id=a[]></textarea>
I have a number of classes and they are quite close to each other
I have a number of classes (more than 40), each one has a number
I have a list of textareas. Each textarea is in a separate div: 1.
I have a textarea that contains phone numbers, each number in a separate line.
I have form with changable content of textareas, from 1 to 5, each time
I have an undefined number of display context and each will display a texture.
I have several html textareas on my site. Each has a submit button. When
I have number of line breaks in a string. But I only want it
I'm stuck with the following scenario and appreciate any help/advice.. Requirement I have number

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.