Jump to content

fmax

New Members
  • Posts

    8
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

fmax's Achievements

Newbie

Newbie (1/5)

0

Reputation

1

Community Answers

  1. (): Argument #1 ($pdo) must be of type object, null given
  2. Hi All Using MVC Model i am stuck on multiple dependent combobox, My first combobox model code is as follows function getCompanyName(object $pdo){ $query = "SELECT * FROM MASTER_COMPANY;"; $companyNameStmt = $pdo->prepare($query); $companyNameStmt->execute(); $companyNameresult = $companyNameStmt->fetchAll(PDO::FETCH_ASSOC); return $companyNameresult; } I want to populate to a combobox <select name="FCompName" id="company-id" class="form-select" required=""> <option value="" disabled selected>--- SELECT COMPANY ---</option> <?php ?> </select>
  3. function getUserName(object $pdo, string $pUserName){ $query = "SELECT LOGIN_USERNAME FROM MASTER_LOGIN WHERE LOGIN_USERNAME = :pUserName;"; $stmt = $pdo->prepare($query); $stmt->bindParam(":pUserName",$pUserName); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result; } function username_exists(object $pdo, string $pUserName){ if(getUserName($pdo, $pUserName)) { return true; } else { return false; } } if (username_exists($pdo, $pUserName)){ $errors["username_exists"] = "Username Already Exists"; }
  4. Dear All I am using below 2 PHP functions to insert data to database. Its returning me " Query Failed : SQLSTATE[HY093]: Invalid parameter number: parameter was not defined " error. When i run the SQL in phpMyAdmin query box its working fine. can anyone advice me where i am wrong in PHP code function getLoginId(object $pdo,string $LogID){ $query = "SELECT * FROM MASTER_LOGIN;"; $stmt = $pdo->prepare($query); $stmt->execute(); $count = $stmt->rowCount(); if($count == 0){ $LogID = "LOG0000001"; return $LogID; } else { $LogID = $count + 1; $LogID = str_pad((string)$LogID, 7,"0", STR_PAD_LEFT); $LogID = "LOG".$LogID; return $LogID; } } function set_user($pdo,$pUserName,$pPassword,$LogID){ $LogID = getLoginId($pdo,$LogID); $query = "INSERT INTO MASTER_LOGIN (LOGIN_ID,LOGIN_USERNAME,LOGIN_PASSWORD) VALUES (:LogID,:pUserName,:pPassword);"; $stmt = $pdo->prepare($query); $options = [ 'cost' => 12 ]; $hashedPwd = password_hash($pPassword, PASSWORD_BCRYPT, $options); $stmt->bindParam(":LOGIN_ID",$LogID); $stmt->bindParam(":LOGIN_USERNAME",$pUserName); $stmt->bindParam(":LOGIN_PASSWORD",$hashedPwd); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result; }
  5. Thank you Danish Hafeez for your reply and giving me your valuable advice, I have turned on error reporting and it popped path of db connection php file. I have used your code but it updated all 8 records but i have kept your advice in mind of preparing statement and parameter binding to solve the issue :)
  6. Thank you Barand for a reply, Yes i just turned on and it popped connection issue of PATH and i have sorted it out using code of Danishhafeez
  7. Dear All In a web application for delete, I am using a different way rather than deleting record directly. In future admin can check who has deleted through collected login details. To achieve this i have created a column named COMPANY_STATUS instead of deleting i will change status to "N". The below code works fine in local machine but not working in web server. It is getting stuck at if(mysqli_query($con,$sql)){} Code is a below <?php if (isset($_GET['COMPANY_ID'])) { include('dataconn/connection.php'); $id = $_GET['COMPANY_ID']; $PCompanySts = "N"; $sql = "UPDATE `MASTER_COMPANY` SET `COMPANY_STATUS`='$PCompanySts' WHERE COMPANY_ID='$id'"; if(mysqli_query($con,$sql)){ session_start(); $_SESSION["delete"] = "Company Deleted Successfully!"; header("Location: /Companyindex.php"); }else{ die("Something went wrong"); } }else{ echo "Company does not exist"; } Can someone guide me, what am i doing wrong
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.