FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Link Add Error





DanielXP
I have change the code of my link adder as i want it to go as

* URL
* Description
* Posted By

I have change the line and change some other codes around this is the code

Code:
<?php

include "style.php";
$filename = 'link.txt'; // edit this

function addlink($link_url,$des,$by) {
global $filename;
$html = "<table border="1" width="293" id="table4"><tr><td align="center" width="94" bgcolor="#7C9CE2">URL:</td><td width="183" bgcolor="#7C9CE2">$link_url</td></tr><tr><td align="center" width="94" bgcolor="#7C9CE2">Description:</td><td width="183" bgcolor="#7C9CE2">$des</td></tr><tr><td align="center" width="94" bgcolor="#7C9CE2">Posted By:</td><td width="183" bgcolor="#7C9CE2">$by</td></tr></table>\n";
$fp = fopen($filename, 'a+');


function logIP($link_url)
{
     $ipLog="log.txt"; // Your logfiles name here (.txt or .html extensions ok)


     $register_globals = (bool) ini_get('register_gobals');
     if ($register_globals) $ip = getenv(REMOTE_ADDR);
     else $ip = $_SERVER['REMOTE_ADDR'];

     $date=date ("l dS of F Y h:i:s A");
     $log=fopen("$ipLog", "a+");

     if (preg_match("/\bhtm\b/i", $ipLog) || preg_match("/\bhtml\b/i", $ipLog))
     {
          fputs($log, "IP: $ip - Link added: $link_url <br>");
     }
     else fputs($log, "IP: $ip - Link added: $link_url \n");

     fclose($log);
}
// Place the below function call wherever you want the script to fire.
logIp($link_url);


fputs($fp, $html) or die("Could not open file!");
echo 'The link was added successfully.<br><br>';

}

function showlinks() {
global $filename;
$html = implode('<br/>',array_reverse(file($filename)));
echo $html;
}


If (!$link_url){
   print "You must enter a Link Address";
} elseif (!$by){
   print "You must enter your Username";
} elseif (!$des){
   print "You must enter a website description";
} else {
   addlink($link_url,$des,$by);
   print "<b>Existing Links</b>:<br>";    // adds new link
   showlinks();                      // display's list of links
}


?>


It comes up this error
Code:
Parse error: parse error, unexpected T_LNUMBER in myurl.com/links/add.php on line 38


The line goes to the line i edited:
Code:
$html = "<table border="1" width="293" id="table4"><tr><td align="center" width="94" bgcolor="#7C9CE2">URL:</td><td width="183" bgcolor="#7C9CE2">$link_url</td></tr><tr><td align="center" width="94" bgcolor="#7C9CE2">Description:</td><td width="183" bgcolor="#7C9CE2">$des</td></tr><tr><td align="center" width="94" bgcolor="#7C9CE2">Posted By:</td><td width="183" bgcolor="#7C9CE2">$by</td></tr></table>\n";


As you can see the code is long but it goes on one line an i would like it to post and display in the same way.

Please help me
mathiaus
you either need a backslash before each quote like \" or do this

Backslashes
Code:
$html = "<table border=\"1\" width=\"293\" id=\"table4\"><tr><td align=\"center\" width=\"94\" bgcolor=\"#7C9CE2\">URL:</td><td width=\"183\" bgcolor=\"#7C9CE2\">$link_url</td></tr><tr><td align=\"center\" width=\"94\" bgcolor=\"#7C9CE2\">Description:</td><td width=\"183\" bgcolor=\"#7C9CE2\">$des</td></tr><tr><td align=\"center\" width=\"94\" bgcolor=\"#7C9CE2\">Posted By:</td><td width=\"183\" bgcolor=\"#7C9CE2\">$by</td></tr></table>\n";



My Prefered method
Code:
$html = <<<HTML
<table border="1" width="293" id="table4"><tr><td align="center" width="94" bgcolor="#7C9CE2">URL:</td><td width="183" bgcolor="#7C9CE2">$link_url</td></tr><tr><td align="center" width="94" bgcolor="#7C9CE2">Description:</td><td width="183" bgcolor="#7C9CE2">$des</td></tr><tr><td align="center" width="94" bgcolor="#7C9CE2">Posted By:</td><td width="183" bgcolor="#7C9CE2">$by</td></tr></table>\n
HTML;
DanielXP
Thanks so much for your help Very Happy
Related topics
PHP Validation Class
[RESOLVED] How to add image or text to link in signature?
[PHP] Error link
My first site :D:D:D
Cafe18.NET ( The Best Indian Forum )
tweaking wordpress
Need help with Members area/link adder
Evaluate my software.
url hover code
mysql tempramental ?
Active Button With Css And Php...
Oberon - hungarian speaking topic about a MMORPG engine
Windows 2008 R2 as additional Domain Controller
PHP Sending Attachment Email
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.