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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:05:09+00:00 2026-05-30T20:05:09+00:00

Hi im using PDO to update some fields of a MySQL database. I’ve written

  • 0

Hi im using PDO to update some fields of a MySQL database. I’ve written a class called “bakeIT” which connects to a DB and updates some fields depending on the parameters of the method simple_update().

Somehow the first instantiation call to BakeIT()->simple_update() is working but not the second one? Why is that? I’m getting really crazy on that…

Edit:
I found out some errors:

string(85) “SQLSTATE[28000] [1045] Access denied for user
‘ODBC’@’localhost’ (using password: NO)” Fatal error: Call to a member
function prepare() on a non-object in
BakeIT.php

The table looks like the following:enter image description here

class BakeIT {

    function simple_update(
    $tablename,
    $fieldname,
    $value,
    $id,
    $idname,
    $token,
    $tokenvalue){

        $conn=$this->connect_db();
        $sql= "UPDATE $tablename SET $fieldname=? WHERE $idname=? AND $token=?";
        $q = $conn->prepare($sql);
        $q->execute(array($value,$id,$tokenvalue));
        $conn = null;}
}


//This as the first query works!        
$saveanchor = new BakeIT();
$saveanchor->simple_update('navigation','anchor','whoo',5,'idnavigation','hash','3234'); 

//This as the second query not!    
$savetitle = new BakeIT();
$savetitle->simple_update('navigation','linkname','kawoom',5,'idnavigation','hash','3234');
  • 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-30T20:05:10+00:00Added an answer on May 30, 2026 at 8:05 pm

    The field linkname doesn’t exists.

    To my comment about the security: So far I know the prepred statemend prevents an attacker to inject any bad values into the field content.

    function example($value, $primarykey, $condition) {
        $q = $conn->prepare("UPDATE table SET somefield=? WHERE $primarykey=?");
        $q->execute(array($value,$condition));
    }
    

    It is not possible to manipulate the parameters $value and $condition but you can set $tableid to 1=1 -- which would override your compleate table.

    E.g. example(12, 34, "1=1 --");that would execute this here:

    UPDATE table SET somefield=12 WHERE 1=1 --=34
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using PDO and MySQL, for some reason when getting values from the database
I'm using PDO to insert a record (mysql and php) $stmt->bindParam(':field1', $field1, PDO::PARAM_STR); $stmt->bindParam(':field2',
I'm using PDO for connect to the database in a system where I want
I am using PDO with PHP to create a new database and then a
Which is the equivalent of mysql_data_seek using pdo objects? Can you give me an
Recently I was going through a blog and noticed some points about using PDO
I'm using this code and I'm beyond frustration: try { $dbh = new PDO('mysql:dbname='
I'm writing some DB routines and I'm using prepared statements. My environment is PDO
Using FullCalendar ( http://arshaw.com/fullcalendar/ ) to pull events from a MySQL database table via
I'm trying to update my database table with PDO, but to avoid security leaks,

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.