Welcome Guest ( Log In | Register )

Bump Topic Topic Closed RSS Feed

Outline · [ Standard ] · Linear+

 Help needed, why this code is not working.

views
     
chriss2010
post Oct 20 2016, 11:40 PM

Getting Started
**
Junior Member
71 posts

Joined: Sep 2009
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
post Oct 21 2016, 03:05 PM

Getting Started
**
Junior Member
150 posts

Joined: Sep 2010
QUOTE(GOPI56 @ Oct 19 2016, 09:48 PM)
I tried eyerything but still not working. What is wrong ? Here is my table columns:

user posted image
*
wtf, varchar max only 255 lah... where got 2555? gila
angch
post Oct 24 2016, 09:06 PM

On my way
****
Junior Member
635 posts

Joined: Jul 2006
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.html
It'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/Varchar

Also, please for the love of FSM, escape your db inputs. https://forum.lowyat.net/topic/3398408

And salt and encrypt your dang passwords. https://www.owasp.org/index.php/Password_Storage_Cheat_Sheet

http://php.net/manual/en/faq.passwords.php

This post has been edited by angch: Oct 24 2016, 09:07 PM
bandit9956
post Nov 3 2016, 09:45 AM

Getting Started
**
Junior Member
65 posts

Joined: Nov 2008
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
post Nov 3 2016, 02:03 PM

opis boi
****
Senior Member
585 posts

Joined: Jan 2007
From: Ranau, Sabah


$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.";
}

Topic ClosedOptions
 

Change to:
| Lo-Fi Version
0.0135sec    0.29    6 queries    GZIP Disabled
Time is now: 29th March 2024 - 11:56 PM