Jump to content

error in Db connection : Parse error: syntax error, unexpected T_STRING


jaganguys

Recommended Posts

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>

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.

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))

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.