What I want, is to fetch the Selected query in an Associative array. The Select query works fine but while fetching the query It gives this error:
Fatal error: Uncaught Error: Undefined class constant 'FECTH_ASSOC' in D:\xampp\htdocs\MyWork\admin\workEdit.php:7 Stack trace: #0 {main} thrown in D:\xampp\htdocs\MyWork\admin\workEdit.php on line 7
Here Are my Code:
connection.php
<?php
class Connection{
static $dbHost ='localhost';
static $dbName ='db_idream_workschedule';
static $dbusername ='root';
static $dbpassword ='';
static $con;
static function connect(){
try{
self::$con = new PDO("mysql:dbHost=".self::$dbHost.";dbname=".self::$dbName,self::$dbusername,self::$dbpassword);
}catch(PDOException $e){
die($e->getMessage());
}
}
}
?>
workTable.php
<a href="workEdit.php?id=<?php echo $row['jobId']; ?>"><i class="fa fa-edit"></i></a> || <a onclick="return confirm('are you sure you want to delete this ?')" href="function.php?id=<?php echo $row['id']; ?>&image=<?php echo $row['media'];?>&page=deleteUser" > <i class="fa fa-trash"></i></a>
This code is to pass the id to another page to edit the data in workEdit.php
workEdit.php
<?php
$id = $_GET['id'];
require_once('connection.php');
$dbcon = new Connection();
$dbcon->connect();
$result=$dbcon::$con->query("SELECT * FROM `work` WHERE jobId=".$id);
$data = $result ->fetch(PDO::FECTH_ASSOC);
?>
I really don't know what is wrong with this code. I've been using the same code before which worked perfectly fine for me but I have no idea why it's not working.Help would really be appreciated :)