jaganguys Posted December 1, 2010 Share Posted December 1, 2010 Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\mywork\unique.php on line 15 <html> <head> <title> </title> </head> <body bgproperties="fixed"> <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $con = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'mywork'; mysql_select_db($dbname, $con); $sql=mysql_query(insert into users (regno,name,gender,date,month,year,emailid,cell,paddress,caddress,incometype,incomeamt,dad,fyes,dadocup,mom,myes,momocup,password) VALUES ('$_POST[regno]','$_POST[name]','$_POST[gender]','$_POST[date]','$_POST[month]','$_POST[year]','$_POST[emailid]','$_POST[cell]','$_POST[paddress]','$_POST[caddress]','$_POST[incometype]','$_POST[incomeamt]','$_POST[dad]','$_POST[fyes]','$_POST[dadocup]','$_POST[mom]','$_POST[myes]','$_POST[momocup]','$_POST[password]')"); $sql1=mysql_fetch_array($sql); $result = @mysql_query($SQl1); $result="SELECT * FROM users WHERE regno='$regno'"; while($row = mysql_fetch_array($result)) { //echo $row['regno']."regno<br>"; //echo $row['name']."name<br>"; //echo $row['gender']."gender<br>"; //echo $row['date']."date<br>"; //echo $row['month']."month<br>"; //echo $row['year']."year<br>"; //echo $row['emailid']."emailid<br>"; //echo $row['cell']."cell<br>"; //echo $row['paddress']."paddress<br>"; //echo $row['caddress']."caddress<br>"; //echo $row['incometype']."incometype<br>"; //echo $row['incomeamt']."incomeamt<br>"; //echo $row['dad']."dad<br>"; //echo $row['fyes']."fyes<br>"; //echo $row['dadocup']."dadocup<br>"; //echo $row['mom']."mom<br>"; //echo $row['myes']."myes<br>"; //echo $row['momocup']."momocup<br>"; //echo $row['password']."password<br>"; } echo "Thanks for Register!"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con); ?> <form name="security" action="index.php" method="post"> <input type="submit" value="click here to login"> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/220340-error-in-db-connection-parse-error-syntax-error-unexpected-t_string/ Share on other sites More sharing options...
trq Posted December 1, 2010 Share Posted December 1, 2010 Simple parse errors mean you need a better editor. If you can't see the incorrect syntax highlighting, again, you need a better editor. $sql=mysql_query("insert into users (regno,name,gender,date,month,year,emailid,cell,paddress,caddress,incometype,incomeamt,dad,fyes,dadocup,mom,myes,momocup,password) VALUES ('$_POST[regno]','$_POST[name]','$_POST[gender]','$_POST[date]','$_POST[month]','$_POST[year]','$_POST[emailid]','$_POST[cell]','$_POST[paddress]','$_POST[caddress]','$_POST[incometype]','$_POST[incomeamt]','$_POST[dad]','$_POST[fyes]','$_POST[dadocup]','$_POST[mom]','$_POST[myes]','$_POST[momocup]','$_POST[password]')"); PS: Don't use user inputted data directly in a query like that (your asking for trouble). See mysql_real_escape_string. Quote Link to comment https://forums.phpfreaks.com/topic/220340-error-in-db-connection-parse-error-syntax-error-unexpected-t_string/#findComment-1141768 Share on other sites More sharing options...
jaganguys Posted December 1, 2010 Author Share Posted December 1, 2010 hi i am getting error Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\mywork\unique.php on line 19 Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in C:\xampp\htdocs\mywork\unique.php on line 21 Thanks for Register! $sql1=mysql_fetch_array($sql); $result="SELECT * FROM users WHERE regno='$regno'"; while($row = mysql_fetch_array($result)) Quote Link to comment https://forums.phpfreaks.com/topic/220340-error-in-db-connection-parse-error-syntax-error-unexpected-t_string/#findComment-1141772 Share on other sites More sharing options...
trq Posted December 1, 2010 Share Posted December 1, 2010 No need for the big type thanks, we can read. You haven't executed your query using mysql_query. Quote Link to comment https://forums.phpfreaks.com/topic/220340-error-in-db-connection-parse-error-syntax-error-unexpected-t_string/#findComment-1141773 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.