0

At the moment I have this code, for uniformity on all pages, I want to change it.

<?php

session_start();
if(isset($_SESSION["UserID"])){
}else{
header('Location: ../Login.php');
}
?>

<?php

include_once 'dbcon.php';

$id = $_POST['id'];
$fn = $_POST['fn'];
$ln = $_POST['ln'];
$em = $_POST['em']; 
$hid = $_POST['hid']; 
$tn = $_POST['tn'];
$us = $_POST['us'];
$pw = $_POST['pw'];
$ul = $_POST['ul'];
$chk = $_POST['chk'];
$chkcount = count($id);
for ($i = 0; $i < $chkcount; $i++) 
{
$pwHash = password_hash($pw[$i], PASSWORD_BCRYPT, array('cost' => 10));

$MySQLiconn->query("UPDATE user SET FName='$fn[$i]', LName='$ln[$i]', Email='$em[$i]', HerbalifeID='$hid[$i]', TelNr='$tn[$i]', UplineS='$us[$i]', Password='$pwHash', UserLevel='$ul[$i]'  WHERE UserID=".$id[$i]);

}

header("Location: indexAdmin.php");
?>

I wan't to change the type of connection to my database.

New type of connection: on the top of my page I use this code (which works on the other pages):

<?php include_once '../Connections/localhost.php'; ?>

When I change

$MySQLiconn->query("UPDATE... 

to

mysqli_query($con, "UPDATE... 

it won't work.

Can anyone help?

Benny
  • 67
  • 4
  • What is $con? What is the error you are getting? – Thijs Tijsma Jun 05 '16 at 13:28
  • Why do you want to switch from object oriented style to procedural style? Sounds like a step back... – arkascha Jun 05 '16 at 13:29
  • $con=mysqli_connect("localhost","my_user","my_password","my_db"); – Benny Jun 05 '16 at 13:30
  • *"When I change $MySQLiconn->query("UPDATE... to mysqli_query($con, "UPDATE... it won't work."* - Look at the variables you're wanting to use here `$MySQLiconn` and your `$con`; what's different? SooOOOooooo `$con->query("UPDATE...` – Funk Forty Niner Jun 05 '16 at 13:34
  • Thanks Fred, $con->query("UPDATE... is working ! – Benny Jun 05 '16 at 13:39
  • you're welcome. The question has been marked as a duplicate since error reporting would have thrown you an undefined MySQLiconn variable notice. http://php.net/manual/en/function.error-reporting.php – Funk Forty Niner Jun 05 '16 at 13:40

0 Answers0