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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:18:27+00:00 2026-06-08T13:18:27+00:00

I’m new to php and think this should work but I can’t figure out

  • 0

I’m new to php and think this should work but I can’t figure out if I’m doing something wrong with syntax or what. This is the script that handles my submitted data from a form.

I set php variables to the posted data from the form, it echos out the correct data in the variables, the problem is with updating the record in the database, it doesn’t…

The table in the DB has 3 attributes, adID, iconURL, webURL.

The form has 2 input textfields, and a hidden field, iconPath, webPath, and recordN.

<?php
$recNum = $_POST["recordN"];
$iconU = $_POST["iconPath"];
$webU = $_POST["webPath"]; 
echo 'Number of record updated: ' . $recNum;
echo '<br />New Icon Path: ' . $iconU;
echo '<br />New Web Path: ' . $webU;

$con = mysql_connect("localhost","admin","pass");
if (!$con)  {   die('Could not connect: ' . mysql_error());   }

mysql_select_db("DBNAME", $con);

mysql_query("UPDATE adSources set iconURL = $iconU, webURL = $webU 
WHERE adID = $recNum");

mysql_close($con);

echo '<br /><a href="http://mydomain.com/thePage.html" target="_blank">Return to main page</a>' . "\n"; 
?> 

So where adID = recNum, I want to overwrite iconURL = $iconU and webURL = $webU

I have the value in $iconU and $webU that I want to use, and iconURL and webURL are the names of the fields in the database. I read them just fine and can display them by those names just fine, I just can’t update this.

I granted full permissions in the db for the user and all that.

Any help? Php seems so freakin ugly compared to other languages.

  • 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-08T13:18:28+00:00Added an answer on June 8, 2026 at 1:18 pm

    You missed out quotes along your variable names. Try:

    mysql_query("UPDATE adSources set iconURL = '$iconU', webURL = '$webU'
                WHERE adID = $recNum");
    

    Better if you could also escape the variables:

    mysql_query("UPDATE adSources set iconURL = '".mysql_real_escape_string($iconU).
                "', webURL = '".mysql_real_escape_string($webU).
                "' WHERE adID = $recNum");
    

    That makes it a little better, but the use of mysql_real_escape_string() is actually discouraged. You should be checking out and replacing it with PDO once you get the hang of it.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I know there's a lot of other questions out there that deal with this
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.