I have reg_dental_camp
table having columns id, reg_name, reg_email, reg_phone, reg_type, reg_info, created_at, updated_at
I want to fetch the table data in Laravel and show them using ajax.
The function I have written is:
public function showUsers(){
$table ="SELECT * FROM `reg_dental_camp`";
$primaryKey = 'id';
$userColumns = array(
array( 'db' => 'id', 'dt' => 'id' ),
array( 'db' => 'reg_name', 'dt' => 'reg_name' ),
array( 'db' => 'reg_email', 'dt' => 'reg_email' ),
array( 'db' => 'reg_phone', 'dt' => 'reg_phone' ),
array( 'db' => 'reg_type', 'dt' => 'reg_type' ),
array( 'db' => 'reg_info', 'dt' => 'reg_info' ),
array(
'db' => 'created_at',
'dt' => 'created_at',
'formatter' => function( $d, $row ) {
return date( 'jS M y', strtotime($d));
}
)
);
if($_SERVER['HTTP_HOST']=='localhost'){
$sql_details = array(
'user' => 'root',
'pass' => '',
'db' => 'ubl',
'host' => 'localhost'
);
}
$userResult = SSP::simple( $_GET, $sql_details, $table, $primaryKey, $userColumns);
print_r($userResult);
}
While visiting from the main page it is showing error number 500 on ajax call URL and visiting directly to the ajax call URL is is giving SQL error SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT * FROM `reg_dental_camp`
How can I solve this problem? Thanks in advance
question from:
https://stackoverflow.com/questions/65878962/laravel-sql-query-is-giving-error-while-calling-from-ajax 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…