www.webdeveloper.com
Results 1 to 15 of 15

Thread: How to show news? Erorr message...Need help

  1. #1
    Join Date
    Sep 2005
    Posts
    1,692

    Question How to show news? Erorr message...Need help

    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
    Mar 2006
    Posts
    52

    Lightbulb Link

    Link si trying to create a hardlink on your system ...

    1. Do you use windows?
    2. if (!1) do you have the necesary rights there ?

    Best Regards
    Adrian

    P.S. http://www.php.net/manual/en/function.link.php

  3. #3
    Join Date
    Sep 2005
    Posts
    1,692
    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 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).
    Last edited by toplisek; 03-26-2006 at 02:48 AM.

  4. #4
    Join Date
    Mar 2006
    Posts
    52

    Lightbulb

    Your program is trying to do a hard link in your system. Try to change that and will work or gove the right permisions on the system. If you are under *nix try to chmod with the owner of your webserver (under debian linux the owner is www-data on other system is apache or www)


    Best Regards
    A.
    P.S. I dont know what is doing your code but try in this way if you are not want to using the "link" (I don't know why you are using link there ? do you declared a function named link ? php have it's own function link and you cannot declare a function with the same name):

    PHP Code:
    echo '<td><A HREF="'article.php?ID='.$_GET['id'].'"><B>'.$rec[$i].'</B></A></td>'; 

  5. #5
    Join Date
    Sep 2005
    Posts
    1,692

    Question

    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?
    Last edited by toplisek; 03-26-2006 at 03:07 AM.

  6. #6
    Join Date
    Feb 2005
    Location
    Tauranga
    Posts
    2,062
    your query on the article.php page would be something this...

    PHP Code:
    <?php

    $q 
    "SELECT field,field,field FROM table where id = '".$_GET['ID']."' ";
    $s mysql_query($q);
    echo(
    mysql_error($s));

     
    $r mysql_fetch_assoc($s);

    //echo the title
    echo("<h1>".$r['title']."</h1><br>"."\n");
    //echo the artcile
    echo("<p>".$r['article']."</p>");

    ?>

  7. #7
    Join Date
    Sep 2005
    Posts
    1,692
    I have put while sentence :
    PHP Code:

        
    // Make rows for records
        
    while($rec=mysql_fetch_array($result))
        {
           echo 
    "<tr>";
            for(
    $i=0;$i<count($rec);$i++)
            {
                if(
    $rec[$i])


    $query "SELECT ID FROM articles where ID = '$rec[$i]' ";
    $s mysql_query($query);
    echo(
    mysql_error($s));

    $result mysql_fetch_assoc($s);
    $ID=$result['ID'];
    //echo the article
    //echo("<p>".$result['ID']."</p>");


                
    echo '<td><a href="article.php?ID='.$ID.'"><B>'.$rec[$i].'</B></A></td>';
            }
            echo 
    "</tr>";
        }
        echo 
    "</table>";

    It gives me error:
    Warning: mysql_error(): supplied resource is not a valid MySQL-Link resource in .../read_news.php on line 59

    Line 59 is:
    echo(mysql_error($s));
    Do you know how is correct to get ID number in this while sentence? Need help

  8. #8
    Join Date
    Mar 2006
    Posts
    52

    Lightbulb

    Quote Originally Posted by toplisek
    I have put while sentence :
    PHP Code:

        
    // Make rows for records
        
    while($rec=mysql_fetch_array($result))
        {
           echo 
    "<tr>";
            for(
    $i=0;$i<count($rec);$i++)
            {
                if(
    $rec[$i])


    $query "SELECT ID FROM articles where ID = '$rec[$i]' ";
    $s mysql_query($query);
    echo(
    mysql_error($s));

    $result mysql_fetch_assoc($s);
    $ID=$result['ID'];
    //echo the article
    //echo("<p>".$result['ID']."</p>");


                
    echo '<td><a href="article.php?ID='.$ID.'"><B>'.$rec[$i].'</B></A></td>';
            }
            echo 
    "</tr>";
        }
        echo 
    "</table>";

    It gives me error:
    Warning: mysql_error(): supplied resource is not a valid MySQL-Link resource in .../read_news.php on line 59

    Line 59 is:
    echo(mysql_error($s));
    Do you know how is correct to get ID number in this while sentence? Need help

    After $query="Select ...." ; add a new line with :
    echo $query."<br>";
    and post the result of this echo here on forum.

    Best Regards
    Adrian

  9. #9
    Join Date
    Sep 2005
    Posts
    1,692
    I have put echo $query."<br>";

    and result is as following:
    SELECT * FROM articles where ID = '1'

    Warning: mysql_error(): supplied resource is not a valid MySQL-Link resource in .../read_news.php on line 57
    SELECT * FROM articles where ID = '2006-03-16'

    Line 57 is: echo(mysql_error($s));

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result .../read_news.php on line 48

    Line 48 is while($rec=mysql_fetch_array($result))

  10. #10
    Join Date
    Mar 2006
    Posts
    52

    Lightbulb

    Only now I see you are using the same variablie name for :
    while($rec=mysql_fetch_array($result))
    and
    $result = mysql_fetch_assoc($s);


    try to use another varable name and I guarantee will work for example:
    $result2 = mysql_fetch_assoc($s);

    and change that on all where you used.

    Best Regards
    Adrian

    myDomainTracker

  11. #11
    Join Date
    Sep 2005
    Posts
    1,692

    Question

    Now it shows all but I have problem that if I put code for error
    like
    PHP Code:
     echo(mysql_error($s)); 
    , it will be full of errors:
    Warning: mysql_error(): supplied resource is not a valid MySQL-Link resource in .../read_news.php on line 57

    Line 57 is: echo(mysql_error($s));

    Problem is that is still not solved link for each column like:
    http://www.mywebsite/article.php?ID=1
    http://www.mywebsite/article.php?ID=2
    http://www.mywebsite/article.php?ID=3
    and ....

    Now is shown correct link just for first column where is ID, but I have four more columns...
    Last edited by toplisek; 03-26-2006 at 02:59 PM.

  12. #12
    Join Date
    Mar 2006
    Posts
    52

    Lightbulb

    try to comment that line or use it in this way attached by your query.

    $result = mysql_query($query) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());

    Anyway if you have a error your php will report that.

    The problem with links:

    Before echo "<tr>"; add echo count($rec)."<br>";

    and tell me the result;

    Best Regards
    Adrian

  13. #13
    Join Date
    Sep 2005
    Posts
    1,692

    Question

    There is no error shown. Problem is:
    1.it gives me just first row
    2.only first column has correct link like:
    http://mywebsite/article.php?id=1
    It should have all columns above link

    I have put echo count($rec)."<br>"; and number is 14

  14. #14
    Join Date
    Mar 2006
    Posts
    52
    1. you looked at your generated html source ?
    2. Is possible to have incorect links in database ?
    3. Is possible to see this link somwhere in internet ? (send on private)
    4. Is possible to have incorect html tags ?

    Best Regards
    Adrian

  15. #15
    Join Date
    Sep 2005
    Posts
    1,692

    Question

    Quote Originally Posted by sacx13
    1. you looked at your generated html source ?
    Please explain question...

    Quote Originally Posted by sacx13
    2. Is possible to have incorect links in database ?
    Links are correct for first row and first column.
    It should generate link as I quoted

    Quote Originally Posted by sacx13
    3. Is possible to see this link somwhere in internet ? (send on private)
    No, it is testing server which is not visible on internet

    Quote Originally Posted by sacx13
    4. Is possible to have incorect html tags ?
    What do you mean?
    Best Regards
    Adrian

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.29316 seconds
  • Memory Usage 3,048KB
  • Queries Executed 13 (?)
More Information
Template Usage (34):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (8)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (15)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (15)postbit
  • (15)postbit_onlinestatus
  • (15)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates