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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.