[Help] Gettin PHP Error?

Junior Spellweaver
Joined
Mar 22, 2008
Messages
145
Reaction score
13
Hi, Im adding a hyperlink to a php code but its showing a error, I wanna see if you guys can help me.

Original Code:
<?php
ob_start();

if($in["username"]){
echo '<center><u><a

href="user.php?user='.$in["username"].'">'.$in["username"].'</a></u>
<br>
<a href="editprofile.php">Edit Profile</a> | <a href="editpassword.php">Edit

Password</a><br>
<a href="editemail.php">Edit E-Mail</a><br>
<a href="pm.php">Private Messages (<strong>'.$in["messages"].'</strong>)<br>
'; if($in["rank"] == 'Administrator'){ echo '<a href="admincp.php">Admin

CP</a><br>'; } echo '
<strong><a

href="javascript:logOut(\''.$in["username"].'\');">Logout</a></strong></center>';
}else{
if($_POST[login]){
$error='';
$username = strip_tags($_POST['username']);
$password = md5(strip_tags($_POST['password']));
$ip = $_SERVER['REMOTE_ADDR'];
if(!$username || !$password){
$error.= 'All fields are requred.<br>';
}else{
$check = mysql_query("SELECT * FROM users WHERE `username` =

'$username'");
if(mysql_num_rows($check) == 0){
$error.= 'The user <strong>'.$username.'</strong> does not

exist.<br>';
}else{
$r = mysql_fetch_array($check);
if($r["banned"] == '1'){
$error.= 'You are currently banned, you can not log

in.<br>';
}else{
if($r["password"] !== $password){
$error.= 'The password you entered is

incorrect.<br>';
}else{
setcookie("id", $r["id"],

time()+(60*60*60*24*5));
setcookie("password", $r["password"],

time()+(60*60*60*24*5));
setcookie("sec", md5($ip),

time()+(60*60*60*24*5));
mysql_query("UPDATE `users` SET `ip` = '$ip'

WHERE `username` = '$username'");
header("Location: index.php");
}
}
}
}
}
if($error){
echo $error;
}
echo '<form method="post">
<input type="text" class="custom" name="username" value="username..." />
<input type="password" class="custom" name="password" value="password" />
<a href="register.php">Register</a> | <a href="forgotpass.php">Forgot

Password?</a>
<input type="submit" class="buttom" value="login" name="login" style="float:

right" />
</form>';
}
?>

I try to add this:
<a href="javascript:ajaxpage('/content/jobs.php', 'contentmid');"> Job Openings </a>

But i get this error:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in D:\xampp\htdocs\usersystem.php on line 48
 
Show me line 48.

EDIT:
PHP:
setcookie("id", $r["id"],

Replace that with:
PHP:
setcookie("id", $r["id"];

// Above is for line 48 ONLY.
 
Last edited:
When trying to add that javascript A LINK, echo it using the following way:

PHP:
<?php
echo "<a href=\"javascript:ajaxpage('/content/jobs.php/', 'contentmid/');\"> Job Openings </a>";
?>

EDIT:
Your user system, so far that I can see is SQL Injectable and the security sucks. You may want to read up on that, and just on a personal note, if you're a beginner and don't know anything about security I would just use sessions to save any trouble.

And always add mysql_real_escape_string();, what the ****, why don't you have them? o-O
 
Last edited:
One more question, how can i turn the javascript hyperlink in a normal one and still work like this.

Before:
Code:
<a href="javascript:ajaxpage('/content/jobs.php', 'contentmid');"> Job Openings </a>

After:
Code:
<a href="/content/jobs.php" target="contentmid"> Job Openings </a>

I tryed this but it wont trigger the Iframe right.
 
One more question, how can i turn the javascript hyperlink in a normal one and still work like this.

Before:
Code:
<a href="javascript:ajaxpage('/content/jobs.php', 'contentmid');"> Job Openings </a>
After:
Code:
<a href="/content/jobs.php" target="contentmid"> Job Openings </a>
I tryed this but it wont trigger the Iframe right.


To link OUTSIDE of a frame try doing target='_top'

Code:
<a href="javascript:ajaxpage('/content/jobs.php', 'contentmid');" target="_top"> Job Openings </a>
After:
Code:
<a href="/content/jobs.php" target="_top"> Job  Openings </a>

Should work fine.
 
If you don't want PHP errors, then make sure you're not coding incorrectly.
I'm not quite sure I know what problems you're having either but I hope someone can help you.
 
You shouldn't be using iFrames or AJAX (in that way) to change the contents of a web-page. Just use normal methods...

With an iframe search engines will send people to "/content/jobs.php" instead of your actual site.

With AJAX I'm not sure if the same will happen or if Search Engines will see the content at all.

Sending users to a whole new page is ideal for situations like this.

AJAX is great for popping out forms or seemlessly submitting forms, popping out special tools like color pickers or for JavaScript games that must use server-side verification. It's not ideal for pulling the site's main content. Beginner AJAX experimenters use it this way, but there's really no good reason.
 
One more question, how can i turn the javascript hyperlink in a normal one and still work like this.

Before:
Code:
<a href="javascript:ajaxpage('/content/jobs.php', 'contentmid');"> Job Openings </a>

After:
Code:
<a href="/content/jobs.php" target="contentmid"> Job Openings </a>

I tryed this but it wont trigger the Iframe right.

Make sure the iframe ID is exactly like your target "contentmid". Otherwise, it will cause errors. I had this problem before with a usersystem. The target & iframe ID didn't match ;)
 
Back