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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:18:59+00:00 2026-05-26T05:18:59+00:00

My first query is this: $sql = UPDATE application SET userid = ? WHERE

  • 0

My first query is this:

$sql = "UPDATE application SET userid = ? WHERE appid = ? LIMIT 1";

My second query is this:

SELECT user.name,application.appid,application.userid,application.created,application.title,application.filesize,application.status,application.apptype 
FROM user,application 
WHERE application.appid = ? LIMIT 1

Then the second query is stored using $statement->fetchObject()

The problem is that $statement->name is always bob. application.userid is a foregin key to userid in table user. If I change the userid in table application, lets say 10, query 2 should get the name from the table user on the new userid, but the problem is that it keeps telling me that $statement->name is bob.

if (isset($_POST['newowner']))
{
    $newowner = $_POST['newowner'];
    $sql = "SELECT COUNT(*) FROM user 
            WHERE userid = ? LIMIT 1";
    $statement = $db->prepare($sql);
    $statement->execute(array($newowner));

    if ($statement->fetchColumn() > 0)
    {
        $sql = "UPDATE application SET userid = ? 
                WHERE appid = ? LIMIT 1";
        $statement = $db->prepare($sql);
        $statement->execute(array($newowner,$_GET['appid']));
        $appdetail->msg = "Owners were successfully changed.";
        $appdetail->type = "success";
    }
    else
    {
        $appdetail->msg = "Could not find client by that userid or email.";
        $appdetail->type = "warning";
    }
}
$sql = "SELECT user.name,application.appid,application.userid,application.created,application.title,application.filesize,application.status,application.apptype 
        FROM user,application 
        WHERE application.appid = ? LIMIT 1";
$statement = $db->prepare($sql);
$statement->execute(array($_GET['appid']));
$app = $statement->fetchObject();
  • 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-26T05:19:00+00:00Added an answer on May 26, 2026 at 5:19 am

    Using PDO you should be able to determine how many rows are affected by the UPDATE. Check that this corresponds to the number of rows you expect to be modified in your test data. Edit: this is the statement you’ll need.

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

Sidebar

Related Questions

I have this query in my sql if (select count(*) from sys.columns where object_id
I'd like to create query like this with QueryDSL update WorkMessage w set w.totalPrice
With :limit in query, I will get first N records. What is the easiest
**Update: Title should have read: Sql Query - Unique item with latest entry Hi
Apologies - am not good at SQL. Perhaps this is a simple query -
Here's the query that is being executed on SQL Server 2008: SELECT "dbo"."tblMainData"."recID" FROM
UPDATE `comment` SET `agree`=`agree`+1,(INSERT INTO `reacted_on` VALUES (10,197)) WHERE `id`=197 and 0 = (SELECT
Looking at similar questions, I actually want the exact opposite of this: SQL query
I can't display the first entry from my query that returns multiple answers. For
I'm using a TableAdapter for the first time and adding a custom query to

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.