TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 411
  • Total: 411

box scripting help

Started by jozeta, January 14, 2008, 11:41:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jozeta

hi
i wannted to make a script that collects random links from the db.
the script works when its in a standalone phpfile, but not in the tpbox.
my knowlege of smf/tp integration is very limited, please help me


<?php

// ansluter till databasen
$opendb mysql_connect("localhost""xxxxxx""xxxxxxx") or die(mysql_error());
mysql_select_db("xxxxxxxx") or die(mysql_error());

// hämtar information frÃ¥n den angivna tabellen
$result mysql_query("SELECT * FROM smf_links ORDER BY RAND() LIMIT 5")
or die(
mysql_error());

// hämtar resultatrader frÃ¥n tabellen
while($row mysql_fetch_array$result ))
     {
     
// skriver ut innehÃ¥llet radvis
echo "<a href='";
echo 
$row['url']."' target='blank'>";     
echo 
$row['title']."</a><br>";
          }

// stänger databasen
mysql_close($opendb);

?>



i understand that the db code is the problem, but what should it be?

please help

best regards johan

jozeta

hehhe got it to work now...
so if any one is intrested and got the SMF link mod

here is a script that displayse x number of random links


global $db_prefix, $scripturl;


$query = db_query(
    "SELECT *
     FROM smf_links
     ORDER BY RAND() LIMIT 5");

while ($row = mysql_fetch_array( $query ))
     {
     // print results
echo "<a href='";
echo $row['url']."' target='blank'>";     
echo $row['title']."</a><br>";
          }


G6Cad

You got it to work by removing the php tags on the first and last row right ;)

This website is proudly hosted on Crocweb Cloud Website Hosting.