LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-15-2010, 02:52 AM   #1
naziya486
LQ Newbie
 
Registered: Oct 2010
Posts: 8

Rep: Reputation: 0
PHP code error please help


hello,

I am getting this error in my php file while testing it on the wamp......and dont know what's the problem??? Please somebody give me suggesion...


Parse error: parse error in C:\wamp\www\Project\signupck.php on line 267

This is the relative coe for the error.
<?php

$query1='';
$query2='';

if(($title != '') &&
isset($firstname) &&
isset($middlename) &&
isset($lastname) &&
($gender != '') &&
isset($dob) &&
isset($ethinicity) &&
($course != '') &&
isset($yearofenroll) &&
($semester != '') &&
($password = $confirm_password)

{
$query1 = "INSERT INTO student (title, f_name, middle_name, l_name, date_of_birth, gender, ethinicity, disability, year_of_enrollement, password) VALUES('$title','$firstname','$middlename','$lastname','$dob','$gender','$ethinicity','$choice_02',' $yearofenroll',$password)";

echo '<tr class="alt">';
echo '<td colspan="3" align="center"><input type="submit" value="Next" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="Cancel" /></td>';
echo '</tr>';

echo '<tr><td height="1" colspan="3"> </td></tr><tr>';
echo '<td height="1" colspan="3"><center><a href="student.php" class="button_bg">Log-In Here</a></center></td></tr>';
}

else
{
echo ('<tr><td colspan="3" class="err">Please fill the form above completely.<br /></tr>');
echo ('<tr><td colspan="3" align="center">');
echo ('<input type="submit" value="Edit" />');
echo ('</td>');
echo ('</tr>');
}

if (mysql_query($query1,$connect))
{
echo ('<tr class="err">');
echo ('<td colspan="3" align="left">You are Registered with STM group of colleges.<br /></td>');
echo ('</tr>');
}
?>
 
Old 10-15-2010, 03:05 AM   #2
Mark1986
Member
 
Registered: Aug 2008
Location: Netherlands
Distribution: Xubuntu
Posts: 87

Rep: Reputation: 11
This IF statement:

if(($title != '') &&

is not ended with a ). Please put a ) before the first { and it should run I think.
 
1 members found this post helpful.
Old 10-15-2010, 04:00 AM   #3
naziya486
LQ Newbie
 
Registered: Oct 2010
Posts: 8

Original Poster
Rep: Reputation: 0
got it

thank you very much it's running now...
 
Old 10-15-2010, 06:05 AM   #4
Mark1986
Member
 
Registered: Aug 2008
Location: Netherlands
Distribution: Xubuntu
Posts: 87

Rep: Reputation: 11
Could you please put this topic on SOLVED? Also please mark my answer as helpful. Thank you very much in advance.

If you need more help, you can contact me using private messages here. I believe you can only encounter PHP problems with your script from now on.
 
Old 10-17-2010, 05:55 PM   #5
naziya486
LQ Newbie
 
Registered: Oct 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Yes I was wondering the same thing when i got my script working but as i am new here i dont know much that how can i add it in the SOLVED. could you please show me? and also about to mark it as helpful...

Thank you very much...
 
Old 10-18-2010, 12:29 AM   #6
Mark1986
Member
 
Registered: Aug 2008
Location: Netherlands
Distribution: Xubuntu
Posts: 87

Rep: Reputation: 11
Marking someone's reply as helpful is located on the right bottom of someone's reply. Click on the text.

To set a thread as solved, you can find this text above the first post: Please Mark this thread as solved if you feel a solution has been provided. Click on the link (blue underlined text) to mark the thread solved.

Thank you very much.
 
1 members found this post helpful.
Old 10-18-2010, 02:42 AM   #7
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 10-18-2010, 07:07 PM   #8
naziya486
LQ Newbie
 
Registered: Oct 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Hello, I was trying to execute my this file called reg_confrmation.php but it gives me the following error:
"Parse error: parse error in C:\wamp\www\Project\reg_confirmation.php on line 119"
in this file line 119 is the closing curly bracket after the echo. but i dont know what's the problem....Please Help..

<?php
if(isset($_POST['submit']))
{
$sql=mysql_query("SELECT * FROM student WHERE ref_no=('".$_SESSION["refno"]."')");

// Mysql_num_rows is counting table row
$result=mysql_num_rows($sql);

if($result==1)
{
echo header("location: alreadyExits.php");
}

else
{
//creating the query for the first table student

$query1 = "INSERT INTO student (title, ref_no, f_name, middle_name, l_name, date_of_birth, gender, house_no, street_name, country, state, postcode, phone_no, e_mail, ethinicity, disability, year_of_enrollement, eme_contact_name, eme_contact_address, eme_contact_postcode, eme_contact_email, eme_contact_phone, password) VALUES('".$_SESSION['title']."', '".$_SESSION['refno']."', '".$_SESSION['firstname']."', '".$_SESSION['middlename']."', '".$_SESSION['lastname']."', '".$_SESSION['dob']."', '".$_SESSION['gender']."', '".$_SESSION['houseno']."', '".$_SESSION['streetname']."', '".$_SESSION['country']."', '".$_SESSION['state']."', '".$_SESSION['postcode']."', '".$_SESSION['phoneno']."', '".$_SESSION['email']."', '".$_SESSION['ethinicity']."', '".$_SESSION['disability']."', '".$_SESSION['yearofenroll']."', '".$_SESSION['emename']."', '".$_SESSION['emeaddress']."', '".$_SESSION['emepostcode']."', '".$_SESSION['emeemail']."', '".$_SESSION['emephoneno']."', '".$_SESSION['password']."')";

}

if (!mysql_query($query1 , $connect))
{
die('Error: ' . mysql_error());
}

else
// function to get Auto generated student_id from student table
{
$student_id = mysql_insert_id();
}

}

echo '<p align="center"><h2>Thank you for using Online Course Registration and Result declaration system.</h2> You will get an email confirmation to access your account.</p>';

}

?>

Thank you in advance
 
Old 10-18-2010, 07:56 PM   #9
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
You have five open braces and six close braces. You will need to look at your code and decide how to modify this so that the braces are properly balanced.
 
Old 10-19-2010, 01:26 AM   #10
Mark1986
Member
 
Registered: Aug 2008
Location: Netherlands
Distribution: Xubuntu
Posts: 87

Rep: Reputation: 11
Yep, it is also a good habit to indent your code like this:

if ($something == true){
$i=1;
}
else{
$i=2;
}

if ($...

etc

That way you and others can read your code much better. Nice to see you actually comment your code, a good habit. Lots of programmers forget that and have no clue what they made a few years later.

Last edited by Mark1986; 10-19-2010 at 01:27 AM. Reason: Just noticed my indents don't show in the forum... Probably yours doesn't either, regard my comment about indent as not said.
 
1 members found this post helpful.
Old 10-20-2010, 08:27 AM   #11
naziya486
LQ Newbie
 
Registered: Oct 2010
Posts: 8

Original Poster
Rep: Reputation: 0
actually i indented in my dreamweaver file but it doesn't show here i dont know why??

Anyways thaks for reply...
 
Old 10-20-2010, 08:42 AM   #12
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
You would need to enclose your listing in [code] tags for the indentation to be reflected
 
1 members found this post helpful.
Old 10-21-2010, 06:24 AM   #13
naziya486
LQ Newbie
 
Registered: Oct 2010
Posts: 8

Original Poster
Rep: Reputation: 0
I would do that from now and on..Thank you very much...

But I changed my code a bit and it still doesn't work. I want the data to be inserted into the table and it doesn't appear into the database..Following is the code..Please Help!!!!!!

Code:
<?php
        include "includes/connection.php"; //coneection to the databse

        include "includes/session.php"; //starts a new session

        //registering of session variables, ie form name values

        session_register('emename');
        session_register('emeaddress');
        session_register('emepostcode');
        session_register('emephoneno');
        session_register('emeemail');

        //storing of posted values in the session variables

        $_SESSION['emename']=$_POST['emename'];
        $_SESSION['emeaddress']=$_POST['emeaddress'];
        $_SESSION['emepostcode']=$_POST['emepostcode'];
        $_SESSION['emephoneno']=$_POST['emephoneno'];
        $_SESSION['emeemail']=$_POST['emeemail'];

  if(isset($_POST['submit']))
  {
	$sql=mysql_query("SELECT * FROM student WHERE ref_no=('".$_SESSION["refno"]."')");
	
	// Mysql_num_rows is counting table row
	$result=mysql_num_rows($sql);
	
	if($result==1)
	{
		echo header("location: login.php");
		echo 'Applicant already exist!';
	}
	
  	else 
	{
		//creating the query for the first table student
		
		$query1 = mysql_query("INSERT INTO student (title, ref_no, f_name, middle_name, l_name, date_of_birth, gender, house_no, street_name, country, state, postcode, phone_no, e_mail, ethinicity, disabilty, year_of_enrollement, eme_contact_name, eme_contact_address, eme_contact_postcode, eme_contact_email, eme_contact_phone, password) VALUES('".$_SESSION['title']."', '".$_SESSION['refno']."', '".$_SESSION['firstname']."', '".$_SESSION['middlename']."', '".$_SESSION['lastname']."', '".$_SESSION['dob']."', '".$_SESSION['gender']."', '".$_SESSION['houseno']."', '".$_SESSION['streetname']."', '".$_SESSION['country']."', '".$_SESSION['state']."', '".$_SESSION['postcode']."', '".$_SESSION['phoneno']."', '".$_SESSION['email']."', '".$_SESSION['ethinicity']."', '".$_SESSION['disability']."', '".$_SESSION['yearofenroll']."', '".$_SESSION['emename']."', '".$_SESSION['emeaddress']."', '".$_SESSION['emepostcode']."', '".$_SESSION['emeemail']."', '".$_SESSION['emephoneno']."', '".$_SESSION['password']."')");
		
		
	}
	
	if (mysql_query($query1 , $connect))
	{
		echo '<p align="center"><h2>Thank you for using Online Course Registration and Result declaration system.</h2> You will get an email confirmation to access your account.</p>';
	 	$student_id = mysql_insert_id();
	}
	
	else
	{
		die('Error: ' . mysql_error());
	}
	//else
	// function to get Auto generated id form applicant table
	//{
	
		//
	//}
	
	mysql_close($connect);
}

?>
Thank you very much....

Last edited by naziya486; 10-21-2010 at 08:33 AM. Reason: Before only put part of the code not the whole coding
 
Old 10-21-2010, 07:07 AM   #14
djsmiley2k
Member
 
Registered: Feb 2005
Location: Coventry, UK
Distribution: Home: Gentoo x86/amd64, Debian ppc. Work: Ubuntu, SuSe, CentOS
Posts: 343
Blog Entries: 1

Rep: Reputation: 72
I dont see you creating $connect?
 
Old 10-22-2010, 03:07 AM   #15
Mark1986
Member
 
Registered: Aug 2008
Location: Netherlands
Distribution: Xubuntu
Posts: 87

Rep: Reputation: 11
What is the error you are getting?

Next to that, I see you don't validate user input. Please note that it is a serious security breach. Everything you get from $_POST can be manipulated by anyone. There are lots of guides to help you program safer in that matter.

Also, it is best to use include_once instead of include. Find the difference on http://nl.php.net/manual/en/function.include.php and http://nl.php.net/manual/en/function.include-once.php
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Yesterday PHP worked just fine and today it wants to serve up the php code. orsty9001 Linux - Server 10 12-12-2008 10:48 AM
php page displaying text that is supposed to be part of php code DragonM15 Programming 9 07-31-2008 04:58 PM
php: writting files code error PB0711 Programming 3 01-29-2007 10:12 PM
merge ASP code with PHP code.. possible ?? ALInux Programming 7 12-30-2005 08:40 AM
Reoccuring error when trying to code php mrobertson Programming 13 06-03-2005 01:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration