Webmastersite.net
Register Log In

Alt to link.php?id=

Comments on Alt to link.php?id=

Jumpin Jack


Usergroup: Customer
Joined: Jan 13, 2005

Total Topics: 23
Total Comments: 50
Posted Jan 24, 2005 - 8:47 AM:

I made a new link field called siterealname where I type the name of the site without spaces and all lowercase letters. ex - Big Top would be bigtop. I want to send my hits out using something like link.php?id=bigtop instead of the link id number.

How can I do it?
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Jan 27, 2005 - 1:56 AM:

That's a dangerous thing to do, since you can't be sure that you'll always remember to keep the names unique. You're likely to eventually end up with two links that have the same name, rendering one of them dead.

In link.php, change
if ($id > 0)

{

$thelink = new onelink('id', $id); // get for frequent later use
if ($thelink->url == '') $action = 'detail'; // if no url, don't try to go to it

}
to

if ($id > 0)

{
$id = $db->rowitem($db->select('id', 'linkstable', "siterealname='$id'"));
$thelink = new onelink('id', $id); // get for frequent later use
if ($thelink->url == '') $action = 'detail'; // if no url, don't try to go to it

}


Then just link in the templates with link.php?id={LINKSITEREALNAME} (you might want to use the mass replacement across all templates option on the 'advanced' page of your admin panel).
Jumpin Jack


Usergroup: Customer
Joined: Jan 13, 2005

Total Topics: 23
Total Comments: 50
Posted Jan 27, 2005 - 1:37 PM:

Thanks but that code doesn't work.

When I click on a link I get the following error.

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /usr/apache/www/htdocs/links/classes/database.php on line 69

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /usr/apache/www/htdocs/links/classes/database.php on line 82

Fatal error: Call to a member function on a non-object in /usr/apache/www/htdocs/links/link.php on line 149
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Jan 27, 2005 - 6:48 PM:

Looks right, if that's actually your field name. Post the debug.
Search thread for
Download thread as
  • 0/5
  • 1
  • 2
  • 3
  • 4
  • 5



This thread is closed, so you cannot post a reply.