Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
date of the last added Link

Posted by torriv (torriv), 6 August 2007
Hello,

I have a little problem that my code will not give me the right date. it only gives me: 1/1/1970

the code is:

Code:
<?php
include "admin/connect.php";
include "admin/var.php";
//main module for chipmunk FFAL script
if(isset($_GET['catid']))
{
 $ID=$_GET['catid'];
 $getcatlink="SELECT * from ffal_categories where ID='$ID'";
 $getcatlink2=mysql_query($getcatlink) or die("Could not get catname");
 $getcatlink3=mysql_fetch_array($getcatlink2);
 print "<A href='index.php'>Hjem</a>--><A href='index.php?catid=".$getcatlink3['ID']."'>".$getcatlink3['catname'] ."</a><br><br>";
 print "<center><h3> .:". $getcatlink3['catname'] ."</h3></center>";
 print "<center><A href='addlink.php'>Legg til en link</a></center><br><br>";
 $getlinks="SELECT * from ffal_links where catparent='$ID' limit $numlinks";
 $getlinks2=mysql_query($getlinks) or die(mysql_error());
 while($getlinks3=mysql_fetch_array($getlinks2))
 {
   $getlinks3[url]=htmlspecialchars($getlinks3[url]);
   $getlinks3[title]=htmlspecialchars($getlinks3[title]);
   $getlinks3[description]=htmlspecialchars($getlinks3[description]);
   $getlinks3[description]=wordwrap($getlinks3[description], 25, "\n", 1);
     print "<center>";
   print "<A href='".$getlinks3['url']."' target='_blank'>".$getlinks3['title']."</a> - ";
   if($allowdescription=="Yes"||$allowdescription=="yes")

   {
        print $getlinks3['Description']."<br>------------------------------------------------------------ <br>";
   }
 }

}
else
{
 $ID=$_GET['catid'];
 $count=0;
 $getcategories="SELECT * from ffal_categories";
 $getcategories2=mysql_query($getcategories) or die(mysql_error());

$catparent="select catparent from ffal_links";
$catparent2=mysql_query($catparent) or die("funker dårlig");
$catparent3=mysql_num_rows($catparent2);
print "<table border='0' cellspacing='10' align='center'>";
print "<tr><td colspan='2'><center><h3>Linker</h3></center><br><center>Det er $catparent3 Linker registrert</center></td></tr>";
while($getcategories3=mysql_fetch_array($getcategories2)) {
      $siste_link= mysql_query("SELECT time FROM `ffal_links` WHERE catparent = " . $getcategories3['ID'] ."");
      $siste_link1 = mysql_fetch_array($siste_link);
      $siste_link3 = date("j/n/Y",$siste_link1);
      $catparent="select catparent from ffal_links WHERE catparent=" . $getcategories3['ID'];
      $catparent2=mysql_query($catparent) or die("funker dårlig");
      $catparent3=mysql_num_rows($catparent2);
          if($count%2==0) {
                print "<tr><td><A href='index.php?catid=" . $getcategories3['ID']."'><b>".$getcategories3['catname']."</b></a> <br>Antall - ($catparent3) <br> Siste lagt til: ";
                if (mysql_num_rows($siste_link) == 0) print "Ingen.";
                else print $siste_link3;
                print "<br></td>";
          } else {
                print "<td><A href='index.php?catid=".$getcategories3['ID']."'><b>".$getcategories3['catname']."</b></a> <br>Antall - ($catparent3)<br> Siste lagt til: ";
                if (mysql_num_rows($siste_link) == 0) print "Ingen.";
                else print $siste_link3;
                print "<br></td>";
          }
      $count++;
 }
 print "<tr><td colspan='2'><center><A href='addlink.php'>Legg til en link</a></center></td></tr>";
 print "</table>";
}
include 'critical.php';
   
     
?>


siste_link is the norwegian word for last link..

can you see any obvious error?

adress to the page is: http://www.trivera.net/linker/index.php

Posted by admin (Graham Ellis), 7 August 2007
mysql_fetch_array returns an array.  Try replacing      
$siste_link1 = mysql_fetch_array($siste_link);
$siste_link3 = date("j/n/Y",$siste_link1);

with
$siste_link1 = mysql_fetch_array($siste_link);
$siste_link3 = date("j/n/Y",$siste_link1[0]);


Posted by torriv (torriv), 7 August 2007
yes! that worked!


can you tell me a little about what [0] does?

Thank you very much again!



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho