Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Reading news from table on server

  1. #1
    Join Date
    Jan 2006
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Reading news from table on server

    I would like to read all articles in rows.

    Do you know why it gives me error
    Warning: link(): Permission denied in ...read_article.php on line 55
    Line 55 is:
    PHP Code:
    echo '<td><A HREF="'.link("article.php""ID=".$_GET['id']).'"><B>'.$rec[$i].'</B></A></td>'

    code is:
    PHP Code:
    <?  

    # Param 1 : MySQL Host Name
    # Param 2 : MySQL Username
    # Param 3 : MySQL Password
    # Param 4 : MySQL Database
    # Param 5 : SQL Statement (SELECT)

    show_table("localhost","...","...","...","SELECT * FROM articles");

    function 
    show_table($hostName,$userName,$passWord,$dataBase,$sqlQuery)
    {
        
    # Connect to MySQL
        
    $conn=mysql_connect("...""...""...");
        
    # Select Database
        
    mysql_select_db($dataBase,$conn);
        
    # Validate SQL Statement
        
    $array=explode(" ORDER",$sqlQuery);
        
    $sqlQuery=$array[0];
        if(!
    strstr($sqlQuery,"SELECT"))
            die(
    "Invalid Query : SQL statement should be a SELECT statement.");
        
    # ORDER records by requested column
        
    if($_GET['order'])
            
    $sqlQuery=$sqlQuery." ORDER BY ".$_GET['order'];
        
    # Execute SQL query
        
    $result=mysql_query($sqlQuery) or die("Invalid Query : ".mysql_error());
        
    $row=mysql_fetch_array($result);
        
    # Check whether NULL records found
        
    if(!mysql_num_rows($result))
            die(
    "No records found.");

        echo 
    "<table border=1><tr>";
        
    # Make the row for table column names
        
    while (list($key$value) = each($row))
        {
            
    $i++;
            if(!(
    $i%2))
               echo 
    "<td><b><a href='?order=$key'>$key</a></td>";
        }
        echo 
    "</tr>";
        
    $result=mysql_query($sqlQuery);

        
    // Make rows for records
        
    while($rec=mysql_fetch_array($result))
        {
            echo 
    "<tr>";
            for(
    $i=0;$i<count($rec);$i++)
            {
                if(
    $rec[$i])
                    echo 
    '<td><A HREF="'.link("article.php""ID=".$_GET['id']).'"><B>'.$rec[$i].'</B></A></td>';

            }
            echo 
    "</tr>";
        }
        echo 
    "</table>";
    }
    ?>

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Could be that you're using a filesystem that doesn't support hardlinks, or possibly that you don't have write permission in the directory in which you're attempting to create the link. Are you sure this is the function you mean to use?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2006
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Is there other possibility for link?

    I would like to read all articles in rows with all coloumns from server (table).

    Each row should have link to e.g. www.mywebsite.com/article?ID=1

    Number should change with articles ID number.

    Fields for article are
    ID
    Date
    Summary
    Content

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Umm... why bother with that? link() just makes a link for you? Is that all it does? I don't care about that.. I'd never bother to memorize it. Just echo a link.

    PHP Code:
    echo '<a href="'.$link.'">linkname</a>'
    ....And include above however you want.

    Can't be that hard, right?

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    link() creates a hard link, a special filesystem structure used to transparently point to another existing file. It has nothing to do with HTML hyperlinks, which is why I was dubious as to whether this was the function the OP intended to use.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Ah.... hmm... seems like he would want a hyperlink.
    What exactly is a hardlink, btw?

    //dragging the thread off topic... sorry 'bout that.

  7. #7
    Join Date
    Jan 2006
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    If I put code on line 55 it is error:
    Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in .../read_news.php on line 55

    Line 55:
    PHP Code:
        echo '<td><a href="'article.php?ID='.$_GET['id'].'"><B>'.$rec[$i].'</B></A></td>'; 
    Each row should have link to e.g. www.mywebsite.com/article?ID=1 in the first row and in second row e.g. www.mywebsite.com/article?ID=2

    Number should change with articles ID number (ID for article is in table in first field).

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    What the heck? That error is saying you should've ended some line with a ;.... meaning your syntax is off.
    BUT.... I don't see a missing semicolon... I've seen that error alot, and its usually quite easy to fix.
    Maybe it's saying there's an open loop.
    I dunno.

  9. #9
    Join Date
    Jan 2006
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I have solved and it works now. Problem was in href=""
    PHP Code:
        echo '<td><a href="article.php?ID='.$_GET['id'].'"><B>'.$rec[$i].'</B></A></td>'
    Do you know how to get $_GET['id'] form table on server where is ID first column?

  10. #10
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Ah, cool. Hmm... guess the error was due to that. strange.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •