Insert doesn't work

<?php 
$servername = 'localhost';
$username = 'root';
$password = '12345qwert';
$dbname='data1';
$con = mysqli_connect($servername , $username , $password , $dbname);
if($con){
	echo"connected to server";
	echo'<br />';
	}
mysqli_select_db($con,'data1');
 $sql = "INSERT INTO users (firstname, lastname, password) VALUES ('d','f','d')";
$query = mysqli_query($con,$sql);
if ($query===false) {
    echo'error';
	}
	else{
		echo'you regitered successfully';}
		mysqli_close($con);
?>

What errors is MySQL returning?

1 Like

its just not inserting to the database

Instead of echoing “error” in case of an error (which doesn’t give much useful information apart from saying there’s an error) take a look at http://php.net/manual/en/mysqli.error.php

first thanks and the error is table is read only how to change it

Please run
SHOW CREATE TABLE users
in the CLI and post the result

table is read only i dont understand why i already cheked all privileges

sho create table users isnt working

“isn’t working” isn’t enough information to be of much help, what error message did you get?

http://dev.mysql.com/doc/refman/5.7/en/show-create-table.html

To use this statement, you must have some privilege for the table

Try running
SHOW CREATE DATABASE data1
in the CLI

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.