Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[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
 
Newbie Spellweaver
Joined
Jul 6, 2010
Messages
40
Reaction score
2
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:
ex visor
Loyal Member
Joined
May 17, 2007
Messages
2,741
Reaction score
937
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 duck, why don't you have them? o-O
 
Last edited:
Junior Spellweaver
Joined
Mar 22, 2008
Messages
145
Reaction score
13
Sorry, I dont now alot about PHP, I learned HTML for the longest time :), Thanks for the help guys.
 
[R8]ℓσℓ32
Loyal Member
Joined
Oct 6, 2008
Messages
1,396
Reaction score
198
Like Aaron said. Check this

Check specially mysql_scape_string(); and mysql_real_scape_string(); for security.
 
Junior Spellweaver
Joined
Mar 22, 2008
Messages
145
Reaction score
13
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.
 
ex visor
Loyal Member
Joined
May 17, 2007
Messages
2,741
Reaction score
937
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.
 
Junior Spellweaver
Joined
Mar 22, 2008
Messages
145
Reaction score
13
But i want it to trigger the Iframe with out throwing up PHP Errors.
 
ex visor
Loyal Member
Joined
May 17, 2007
Messages
2,741
Reaction score
937
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.
 
Joined
Jun 8, 2007
Messages
1,985
Reaction score
490
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.
 
Junior Spellweaver
Joined
Mar 22, 2008
Messages
145
Reaction score
13
Thanks man, I was thinking about the same thing. I'll save all the trouble and do your method.
 
Joined
Jun 15, 2007
Messages
3,153
Reaction score
1,252
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
Top