Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating Error #24

Closed
tomecerqueira opened this issue Sep 11, 2015 · 1 comment
Closed

Updating Error #24

tomecerqueira opened this issue Sep 11, 2015 · 1 comment

Comments

@tomecerqueira
Copy link

Hi there!
I cannot update my table when i change information. The row highlighted red and not update the information

update.php

<?php

/*
 * 
 * This file is part of EditableGrid.
 * http://editablegrid.net
 *
 * Copyright (c) 2011 Webismymind SPRL
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://editablegrid.net/license
 */

require_once('config.php');         

// Database connection                                   
$mysqli = mysqli_init();
$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
$mysqli->real_connect($config['db_host'],$config['db_user'],$config['db_password'],$config['db_name']); 

// Get all parameters provided by the javascript
$colname = $mysqli->real_escape_string(strip_tags($_POST['colname']));
$id = $mysqli->real_escape_string(strip_tags($_POST['id']));
$coltype = $mysqli->real_escape_string(strip_tags($_POST['coltype']));
$value = $mysqli->real_escape_string(strip_tags($_POST['newvalue']));
$tablename = $mysqli->real_escape_string(strip_tags($_POST['tablename']));



// This very generic. So this script can be used to update several tables.
$return=false;
if ( $stmt = $mysqli->prepare("UPDATE $tablename SET $colname = $value WHERE idoferta = $id")) {
    $return = $stmt->execute();
    $stmt->close();

}             
$mysqli->close();        

echo $return ? "ok" : "error";

If you need anything else, let me know.
Thank You for the help ;)

@tomecerqueira
Copy link
Author

My bad...

I deleted some important parts, like this:

Previous

if ( $stmt = $mysqli->prepare("UPDATE $tablename SET $colname = $value WHERE idoferta = $id")) {
    $return = $stmt->execute();
    $stmt->close();

}

After

if ( $stmt = $mysqli->prepare("UPDATE ".$tablename." SET ".$colname." = ? WHERE idoferta = ?")) {
    $stmt->bind_param("si",$value, $id);
    $return = $stmt->execute();
    $stmt->close();

}

I deleted the parameters and change the '?' in the query. Sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant