Jump to content

PDO not updating database

vorticalbox
Go to solution Solved by keja,

You have a typo :)

 

doctorNumber=':docterNumber',

=>

doctorNumber=':doctorNumber',

Action completes with no errors but doesn't update the database. I know i have to be missing something i just can't see it

		$sql = db::query("UPDATE players set 							name=':name', 							sru=':sru',							address=':address',							dob=':dob',							number=':number',							mobile=':mobile',							email=':email',							kin=':kin',							kinNumber=':kinNumber',							doctor=':doctor',							doctorNumber=':docterNumber',							issues=':issues',							position=':position',							team=':team'							WHERE ID=':ID'",				array				(					":ID" => $_POST['ID'],					":name" => $_POST['name'],					":sru" => $_POST['sru'],					":address" => $_POST['address'],					":dob" => $_POST['dob'],					":number" => $_POST['number'],					":mobile" => $_POST['mobile'],					":email" => $_POST['email'],					":kin" => $_POST['kin'],					":kinNumber" => $_POST['kinNumber'],					":doctor" => $_POST['doctor'],					":doctorNumber" => $_POST['docNumber'],					":issues" => $_POST['issues'],					":position" => $_POST['position'],					":team" => $_POST['team']				)			);		if($sql)		{			do_alert("Player updated");			redirect("../index.php?page=Player");		}

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

You have to remove the ' around your variables :)

 

something = :something_without_pings,

Link to comment
Share on other sites

Link to post
Share on other sites

You have to remove the ' around your variables :)

 

something = :something_without_pings,

I had it like that but then it throws this error.

 

 

 

 

Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined inC:\xampp\htdocs\Admin\includes\database.php on line 13

Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number in C:\xampp\htdocs\Admin\includes\database.php on line 13

  

 

database.php

<?phpclass db {    private static $handle;    public static function connect($host, $username, $password, $db){        self::$handle = new PDO("mysql:host={$host};dbname={$db}", $username, $password);        self::$handle->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );    }    public static function query($sql, $args=null){        $sth = self::$handle->prepare($sql);        $sth->execute($args);        return $sth;    }}?>

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

You have a typo :)

 

doctorNumber=':docterNumber',

=>

doctorNumber=':doctorNumber',

Link to comment
Share on other sites

Link to post
Share on other sites

You have a typo :)

 

doctorNumber=':docterNumber',

=>

doctorNumber=':doctorNumber',

-.- i have php xD thanks

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×