![]() |
Can you find the mistake in this code
<?php
$username = $_POST['username']; $password = md5($_POST['password']); $connect = mysql_connect("localhost","prashant_shankar","shan kar") or die ("Couldn't connect"); mysql_select_db("prashant_inspirations") or die("Couldn't find db"); $query1 = mysql_query("INSERT INTO `prashant_inspirations`.`user_acc` (`uid` ,`username` ,`password`) VALUES(NULL , `$username`,`$password`)") or die ("Couldn't update in user"); mysql_query($query1); ?> The DBname is perfect, it shows that it cant update user table, anything wrong in the syntax , can u correct me.Thanks in advance. |
The following
or die will help you to ascertain what the problem is specifically. Run this code and please tell us what the problem is according to MySQL, if you can't figure it out.php Code:
|
This is to insert a new row so that people can register to login to diff pages.i complied the page and i got this error when i entered new username to be added.
Unknown column 'shankar' in 'field list' where shankar was the new username to be added.Given as an input thru textbox. |
|
You're using backticks (
`) to wrap the username/password strings in the VALUES portion of the query: use quotes instead.Also, if your uid column is an auto-incrementing primary key, there is no need to include it in the query at all. |
but still its not working....i made the following changes
<?php $username = $_POST['username']; $password = md5($_POST['password']); $type= "Guest"; $connect = mysql_connect("localhost","root","") or die ("Couldn't connect"); mysql_select_db("inspirations") or die("Couldn't find db"); $query1 = mysql_query("INSERT INTO `school_inspirations`.`user_acc` (`username` ,`password`,'type') VALUES ( '$username','$password','$type')") or die ("Couldn't update in user"); mysql_query($query1); ?> error Couldn't update in user <?php $username = $_POST['username']; $password = md5($_POST['password']); $type= "Guest"; $connect = mysql_connect("localhost","root","") or die ("Couldn't connect"); mysql_select_db("inspirations") or die("Couldn't find db"); $query1 = mysql_query("INSERT INTO `school_inspirations`.`user_acc` (`username` ,`password`,'type') VALUES ( '$username','$password','$type')") or die (mysql_error()); mysql_query($query1); ?> error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''type') VALUES ( 'adsfa','912ec803b2ce49e4a541068d495ab570','Guest' )' at line 1 |
Thank you everyone.. i found it..thank you
|
| All times are GMT. The time now is 12:41 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0