Jump to content

can a variable hold a link?


conan318

Recommended Posts

$amessage ='<a href='freindacept?username=.$info['username']}.php'>Has sent you a freind request </a>';

 

same thing trying to post link to the database then return it later having trouble getting the syntax right.

 

Parse error: syntax error, unexpected T_STRING in /home/a7817347/public_html/freinds.php on line 6

Link to comment
Share on other sites

You're using quotes to mark the start and end of the string, but you're also using quotes inside the string.  And the syntax for interpolating the variable is a bit off.  Try this:

 

$amessage ='<a href="freindacept?username={$info['username']}.php">Has sent you a freind request </a>';

 

BTW it is "friend", not "freind".  Also you might be wanting this:

 

$amessage ='<a href="freindacept.php?username={$info['username']}">Has sent you a freind request </a>';

Link to comment
Share on other sites

here's the full code i have pretty much if someone clicks on a users profile and presses contact request link i wanting to send the link to confirm friends to alog which then shows up in the other users activity log if they press the link friends are confirmed then it takes both there users names and records them into the friends database.

 

still getting Parse error: syntax error, unexpected T_STRING

 

session_start();
require "database.php";
$myusername=$_SESSION['myusername'];
$getuname=$_POST['to_user'];
$amessage ='<a href="freindacept.php?username={$info['username']}">Has sent you a friend request </a>';
$message=$_POST['message'];




if (!isset($_GET['username'])) {
       $data = mysql_query("SELECT * FROM users LEFT JOIN status  ON status.username=users.username WHERE status.username = '".$_SESSION['myusername']."' ORDER BY id DESC LIMIT 1;") or die(mysql_error());
}  else  {
       $getuname = mysql_real_escape_string($_GET['username']);
       $data = mysql_query("SELECT * FROM users LEFT JOIN status  ON status.username=users.username WHERE status.username = '".$getuname."' ORDER BY id DESC LIMIT 1;") or die(mysql_error());



mysql_query("INSERT INTO alog (from_user, to_user, message ) VALUES ('$myusername', '$getuname','$amessage')") OR die("A log error <br>".mysql_error()); 
}



Echo 'freind request sent';

?>

still getting Parse error: syntax error, unexpected T_STRING

Link to comment
Share on other sites

it kinda working but when i click the link it takes me to http://datenight.netne.net/freindacept.php?username=

so its not passing the varaible

 

$data = mysql_query("SELECT * FROM alog, users WHERE from_user=users.username AND  alog.to_user='$myusername'  ORDER BY alog.id DESC LIMIT 10;") or die(mysql_error());
//Puts it into an array 
while($info = mysql_fetch_array( $data )) 
{

?>


<div class="chatroom">
  <?


Echo "<a href='viewprofile.php?username={$info['username']}'><img src='http://datenight.netne.net/images/".$info['img'] ."' width='30' height='30''></a>".$info['from_user']." ".$info['message'];


  }
?>
[code]

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.