Need help

Started on the old forum in February 2011 · view the original in the archive · old links redirect here

6 replies · 358 views · started 15 years ago · 1 min read

2 participants
alin90 Junior · 31 posts #1

Hi again:) . I have anoher problem : I want to make a page to display the download categories and last time those categories were updated. I coded this

        $cat = intval($_GET['cat']);
        $zap = mysql_query("SELECT * FROM `download` WHERE `refid` = '$cat' ORDER BY `type` ASC, `time` Desc, `name` ASC LIMIT " . $start . "," . $kmess);
        while ($zap2 = mysql_fetch_array($zap)) {
        echo '<a href="index.php?cat=' . $zap2['id'] . '">' . $zap2['text'] . '</a>';
 $file = mysql_query("SELECT COUNT(*) FROM `download` WHERE `type` = 'file' AND `adres` LIKE '" . ($zap2['adres'] . '/' . $zap2['name']) . "%' AND `time` > '" . $old . "'");
$file1 = mysql_query("select * from `download` where type = 'file' and id = '" . $file . "';");
$file2 = mysql_num_rows($file1);
$adrfile = mysql_fetch_array($file1);
$filtime = filemtime("$adrfile[name]");
$filtime = date("d.m.Y", $filtime);

echo 'last update :</b> ' . $filtime . '<br/>';

but i get a strange date .Here is the printscreen.

in atachament must display updated, but i forgot to change:P

Attachments: printscreen.JPG
frostymarvelous Senior · 266 posts #2

You are not supplying a valid timestring to the date function. Most likely, your filemtime() cannot locate the file. Make sure you are pointing to the file by including the rule path

Perfection comes at a cost

I accept liberty!

alin90 Junior · 31 posts #3

frostymarvelous wrote: You are not supplying a valid timestring to the date function. Most likely, your filemtime() cannot locate the file. Make sure you are pointing to the file by including the rule path

Can you give me an example based on my script? I searched on php.net for documentation, i found something about filetime()

<?php
// outputs e.g.  somefile.txt was last modified: December 29 2002 22:16:23.

$filename = 'somefile.txt';
if (file_exists($filename)) {
    echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));
}
?>

I cannot figure how to point to my file. I tried :

$filtime = filemtime("$adrfile[adres]/$adrfile[name]");

but i'm getting this error Warning: filemtime() [function.filemtime]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (:/usr/local/lib/php/) in *****/mobylex.info/download/noutati.php on line 26

frostymarvelous Senior · 266 posts #4

Are you on a free host?

Well, try './somefile.ext'

Perfection comes at a cost

I accept liberty!

frostymarvelous Senior · 266 posts #6

As I said, add the path to the file.

'./' means the same directory as the script ./dir/ means a directory called dir in the Sam directory ../ means the directory before the script

And so forth. Just learn about file paths. This might help PHP - File And Directory Manipulation In PHP (part 2) - The Right Path - PHP - Dev Shed not too good, but okay.

I'm sure you are on a free host and thus base dir is blocked so you need to specify the exact path. Or maybe the include path is wrong. I neve had this problem since I always specify full paths.

Perfection comes at a cost

I accept liberty!

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close