Results 1 to 7 of 7

Thread: Mysql Query Problem

  1. #1
    Join Date
    May 2008
    Posts
    17

    Unhappy Mysql Query Problem

    Hi,

    I enter a query mysql going to count visits to each detail page in this way:

    <%php%>
    $db_host = "";
    $db_user = "";
    $db_password = "";
    $db_name = "";

    $db = mysql_connect($db_host, $db_user, $db_password);
    mysql_select_db($db_name, $db);
    $query="UPDATE idx_link set hits2 = hits2 + 1 where link_id = '<%$link_id%>'";
    $ris=mysql_query($query, $db);


    <%/php%>


    The problem is that the variable "$link_id" is not valued and the number of visits is not increased.

    I tried to manually assign the value to $link_id and in this way it works.

    $query="UPDATE idx_link set hits2 = hits2 + 1 where link_id = '1210'";


    Why the variable $ link_id is not valued?

    Where mistake?


    Thanks

  2. #2
    Join Date
    May 2007
    Location
    NJ, United States
    Posts
    1,651

    Default

    What file / page are you trying to add this to??? More than likely, the problem is that $link_id is bot being passed to the page your trying to add the code to.
    FSGDAG | IndexU Hosting | Owner
    Website | NiceCoder Script Hosting and More! | Web4URL is For Sale!
    Follow Us On Twitter | FaceBook Profile | YouTube Videos

  3. #3
    Join Date
    May 2008
    Posts
    17

    Default

    Thanks for your answer ..........

    This page is detail_link.html, it seems that $link_id not be valued in the query.

    Thanks

  4. #4
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    <%php%>
    $db_host = "";
    $db_user = "";
    $db_password = "";
    $db_name = "";

    is all completely un-necessary unless you're connecting to a different database than IndexU already does. That information is already supplied by the include of application.php

    $link_id is a valid variable IF you are reading detail.php. My guess is that your php is running before the variables are set.

  5. #5
    Join Date
    May 2008
    Posts
    17

    Default

    Hi Bruce, thank you for your reply.

    I can not understand, if the code php is positioned to the top detail_link.html the variable $link_id in the query should valorise.

    I do not know what to think more

  6. #6
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    I'm not a programmer, but get rid of the database connection part and it may just work. What I"m thinking is that because you're bypassing application.php you are no longer including any files and there is nowhere to pull the variables from.

  7. #7
    Join Date
    May 2008
    Posts
    17

    Default

    It seems that the variable $link_id not be exploited within tag <%php%> <%/php%> and honestly I can not understand the reason for this error!

    How do I work around the obstacle?


    Thanks

Similar Threads

  1. Query help, please
    By aladdin1 in forum v5.x
    Replies: 6
    Last Post: 01-23-2008, 08:11 AM
  2. from Mysql 3 to Mysql 5, problems!
    By minder in forum Indexu Lite
    Replies: 1
    Last Post: 05-29-2006, 01:08 AM
  3. MySQL Problem with Connections
    By sweepsmaster in forum v5.x
    Replies: 14
    Last Post: 08-10-2005, 09:16 AM
  4. Need some help with this query.
    By Hart_House in forum v3.2
    Replies: 8
    Last Post: 10-05-2004, 10:10 PM
  5. Query Box
    By craven in forum v5.x
    Replies: 5
    Last Post: 04-28-2003, 08:14 PM

Posting Permissions

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