Outline ·
[ Standard ] ·
Linear+
Help needed, why this code is not working.
chriss2010
|
Oct 20 2016, 11:40 PM
|
Getting Started
|
QUOTE(GOPI56 @ Oct 20 2016, 11:04 PM) CODE $sql = "INSERT INTO tbl_users (userid, username, password, useremail) VALUES ('','$username', '$email', '$pass')"; exclude userid and its value since it's auto increment/primary key CODE $sql = "INSERT INTO tbl_users (username, password, useremail) VALUES ('$username', '$email', '$pass')";
|
|
|
|
Fork
|
Oct 21 2016, 03:05 PM
|
Getting Started
|
QUOTE(GOPI56 @ Oct 19 2016, 09:48 PM) I tried eyerything but still not working. What is wrong ? Here is my table columns: wtf, varchar max only 255 lah... where got 2555? gila
|
|
|
|
angch
|
Oct 24 2016, 09:06 PM
|
|
QUOTE(Fork @ Oct 21 2016, 03:05 PM) wtf, varchar max only 255 lah... where got 2555? gila Someone never keep up with SQL database server changes? http://dev.mysql.com/doc/refman/5.7/en/col...ount-limit.htmlIt's never been limited to 255 for a long, long time. MySQL doesn't, PostgreSQL doesn't, Oracle doesn't, MS SQL Server doesn't. https://en.wikipedia.org/wiki/VarcharAlso, please for the love of FSM, escape your db inputs. https://forum.lowyat.net/topic/3398408And salt and encrypt your dang passwords. https://www.owasp.org/index.php/Password_Storage_Cheat_Sheethttp://php.net/manual/en/faq.passwords.phpThis post has been edited by angch: Oct 24 2016, 09:07 PM
|
|
|
|
bandit9956
|
Nov 3 2016, 09:45 AM
|
Getting Started
|
CODE function connectDatabase() {
$connect = mysql_connect('localhost','root','');
mysql_query('SET NAMES utf8');
if($connect) {
mysql_select_db('users', $connect); } }
Try this way to connect to database.
|
|
|
|
scar_face008
|
Nov 3 2016, 02:03 PM
|
|
$sql = "INSERT INTO tbl_users (userid, username, password, useremail) VALUES ('','$username', '$email', '$pass')"; if ($conn->query($sql) === TRUE) { $smsg = "User Created Successfully."; }
change into:
$sql = "INSERT INTO tbl_users (userid, username, useremail, password) VALUES ('','$username', '$email', '$pass')"; if ($conn->exec($sql)) { //no $result is returned can use // if (mysqli_query($conn, $sql)) { $smsg = "User Created Successfully."; }
|
|
|
|