Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vimal1999's avatar

sql query while inserting in laravel gives error

$query = "insert into users (balance,i_customer,name,password,porta_domain,email,phone_number,company,added_by,customer_id,num_failed_current,fname,lname,zip_code,street,city,state,country) values (0 ," . $i_customer . ", '" . $cid . "' , '" . $defaultPassword . "' , 'ach.com', '" . $contact[0]['email'] . "', '" . $contact[0]['phonenumber'] . "' ,'" . $request->input('company') . " '," . $addedBy . ",'" . $cid . "' ," . $auto . ",'" . $contact[0]['f_name'] . "','" . $contact[0]['l_name'] . "','" . $request->input('zip') . "', '" . $request->input('address').$request->input('address_2') . "', '" . $request->input('city') . "', '" . $state . "','" . $country . "' )"; \DB::select($query);

It is showing error PDOException: 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 ' '67352' , '@c3C!0ut!ng' , 'google.com', 'test99@gmail.com', '9999999999 ' at line 1 in /var/www/html/admin/vendor/laravel/framework/src/Illuminate/Database/Connection.php:326

0 likes
1 reply
Sinnbeck's avatar

Please format your code by adding ``` on the line before and after it

Please or to participate in this conversation.