Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-29-2011, 06:54 PM   PM User | #1
buzz23
New to the CF scene

 
Join Date: Oct 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
buzz23 is an unknown quantity at this point
$end error on last line

Hi

First try at something like this so bear with me...

My Problem: I don't know how much of my code works because I am getting an $end error on line 75 - the last line of the page. What am I doing wrong? The internet seems to tell me that I have missed a bracket somewhere, but neither Dreamweaver or I can find this....

My code:
PHP Code:
<head>
<?php session_start();
$host="localhost";
$username="****";
$password="****";
$db_name="*****";
$uname mysql_real_escape_string$_session["myusername"] );
mysql_connect("$host""$username""$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
if (!isset(
$_SESSION['myusername']) || empty($_SESSION['myusername'])) {;
include 
"logout.php";
}
if(isset(
$_COOKIE['ID_mrtg'])) ;

$username $_COOKIE['myusername']; 
$password $_COOKIE['mypassword']; 
$check mysql_query("SELECT * FROM members WHERE username = '$myusername'")or die(mysql_error()); 
$name mysql_query("SELECT `name` FROM members WHERE username = '$myusername'")or die(mysql_error()); 
while(
$info mysql_fetch_array$check )) ;

if (
$password != $info['mypassword']);
header("Location: logout.php"); 
?> 
<br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My PHP System</title>
<style type="text/css">
body,td,th {
    font-family: DINPro-Medium, Arial;
    font-size: 18px;
    color: #E9D3A2;
    background-color: #A0131B;
}
body {
    background-color: #78131B;
    color: #E9D3A2;
    text-align: left;
}
.right {
    text-align: right;
}
a:link {
    color: #E9D3A2;
}
a:visited {
    color: #E9D3A2;
}
#userauth {
    text-align:right;
}
a:hover {
    color: #E9D3A2;
}
a:active {
    color: #E9D3A2;
}
</style>
</head>
<body> 
<p>
</p>
<a href="\logout.php">Logout</a>
<p><img src="Header.png" alt="Header" width="449" height="254" align="middle" />
  Welcome <?php echo $myusername ?> ! Thank you for logging in.
Please click on an option below:</p>
<p>Option 1</p>
<p>Option 2</p>
<p>Option 3</p>
<p>Option 4</p>
<p></p> 
<span class="right">(C) JA 2011</span>
<p>&nbsp;</p>
<p><a href="http://LINK TO PHPMYADMIN>Administration</a></p>
</body>
</html>
Any help at all would be very much appreciated

Thanks

Last edited by buzz23; 10-29-2011 at 06:58 PM.. Reason: BTW, if you could give me a pointer on ' & " s that would be good - what goes around variables?? Thanks
buzz23 is offline   Reply With Quote
Old 10-29-2011, 07:25 PM   PM User | #2
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,602
Thanks: 2
Thanked 398 Times in 391 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
Unexpected $end means you haven't closed one of your code blocks like this one:
PHP Code:
if(isset($_COOKIE['ID_mrtg'])) 

You need to have a closing curly brace after the end of the code you want this condition to execute. Also, you have semicolons on lines that aren't terminating or assignment. See the difference?
PHP Code:
$password $_COOKIE['mypassword']; // end of the statement "<something> equals <something>" -- assignment
if ($password != $info['mypassword']); // NOT the end of the statement; "if <something> does not equal <something> then..." -- beginning of conditional statement 
Inigoesdr is offline   Reply With Quote
Old 10-29-2011, 07:43 PM   PM User | #3
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,519
Thanks: 45
Thanked 440 Times in 429 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
I've found some problems in your code:
PHP Code:
if (!isset($_SESSION['myusername']) || empty($_SESSION['myusername'])) {;
include 
"logout.php"
You have a semicolon ; after an opening brace - remove it.

PHP Code:
if(isset($_COOKIE['ID_mrtg'])) ; 
Sei colon before the opening brace - remove it.

PHP Code:
<?php echo $myusername ?>
No semicolon at all - put one in.

You might also like to look at the link in my signature about coding styles and $end errors as it may be useful to you.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is online now   Reply With Quote
Users who have thanked tangoforce for this post:
buzz23 (10-30-2011)
Old 10-30-2011, 11:07 AM   PM User | #4
buzz23
New to the CF scene

 
Join Date: Oct 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
buzz23 is an unknown quantity at this point
Thanks very much to both of you for your helpful answers. Together they have solved my problem, and tangoforce's tutorial has been really helpful!

Thanks
buzz23 is offline   Reply With Quote
Reply

Bookmarks

Tags
$end, error

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:07 PM.


Advertisement
Log in to turn off these ads.