Get exclusive CAP network offers from top brands

View CAP Offers

php question

[bsa_pro_ad_space id=2]
  • This topic is empty.
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #611469
    Anonymous
    Inactive

    I’m trying to set up a redirect using a database. I wrote the follow code and it works but pulls up a 404 at the header line. Someone please check the code and tell what is wrong.

    $url = “casino.php?ID=”.$_GET[ID];

    $link = mysql_connect (“localhost”, “user”, “pswd”)
    or exit ();
    mysql_select_db (“db”)
    or exit ();

    // Get all the data from the “links” table
    $query = “SELECT link FROM links where (id=’$_GET[ID]’)”;
    $result = mysql_query ($query)
    or exit ();
    $row = mysql_fetch_object($result);

    header(‘Location: $row’);
    mysql_close($link);
    ?>

    Thanks

    #779909
    Anonymous
    Inactive

    try somthing like this

    Code:
    Start php
    include(“../cpconfig.php”); // load db data for connection
    if ( isset($HTTP_GET_VARS[‘id’]) || isset($HTTP_POST_VARS[‘id’]) ) // get ID # of casino
    {
    $id = ( isset($HTTP_POST_VARS[‘id’]) ) ? htmlspecialchars($HTTP_POST_VARS[‘id’]) : htmlspecialchars($HTTP_GET_VARS[‘id’]);
    }

    $update_clicks-mysql_query(“update p_casinos set bclick=bclick+1 where id=’$id'”); // increase counting f tracing clcks
    $get_rows=mysql_query(“select * from p_casinos where id=’$id'”); // select casino from db
    $get_url=@mysql_fetch_array($get_rows);
    $clickurl=$get_url[url]; // get the url to redirect to

    header(“Location: $clickurl”); // redirect to the casino
    ?>

    #779912
    Anonymous
    Inactive

    Thanks that helped.

    #779913
    Anonymous
    Inactive

    Foun out “links” is a reserved word in MySQL

    SELECT link FROM links where (id=’$_GET[ID]

    Thanks for your help

    #779960
    Anonymous
    Inactive

    Hi Erik,

    Just some comments using your own code:

    1) $url = “casino.php?ID=”.$_GET[ID];

    It seems that it has no use in the part you sent.

    2) If you are getting a 404, it is because the “header” has an invalid URL. So:

    a) Since it is:
    $row = mysql_fetch_object($result);
    $row it is an array thus, it wouldnt work as you posted.
    b) Should be:
    header(‘Location: ‘.$row[0]);

    3) There is an easy way to test what you are sending to the header. You print and ask the script to stop like this:
    echo ‘URL: >’.$row[0].’<';
    die;

    4) You should close the database connection prior to the header redirection.

    That is it.

    #779973
    winner.com
    Member

    a different php question

    Do you know how to have text and image links open in a new window?

    is there something on the back end i have to switch?

    #779990
    Anonymous
    Inactive

    It is simple. Add this on each link:

    target=”_new”

    example:
    online casino portal

    #780182
    winner.com
    Member

    Thanks, bot it still didn’t work. ‘new’ or ‘blank’ get stripped in the html code when saved or uploaded

    #780187
    Anonymous
    Inactive

    hmmm…

    If you are ftping the code directly to the server that won’t happen.

    Since you are talking about SQL and so on in the post, it is hard to understand how your code is doing but I suspect that you have some kind of html form and submit the html… or, you are entering it directly to the db. If this is the case, you will need to clean the html prior to inserting to the db… something like this:

    online casino portal

    or… you may try to mimic the same situation just before you insert the data in to the db.

    #780202
    winner.com
    Member

    Thanks – I’ll give it a shot

    #780205
    Anonymous
    Inactive

    I always use a single ` for php code and ” double quotes for using inside strings to elimate these issues..

    But if your sating youe just using plain html then theres somthing up with how your getting it there,,

    for instance


    $var=”http://”www.site.com”&#8221;;

    will get hosed while

    $var=’http://”www.site.com”&#8216;;

    will be ok

    #780241
    Anonymous
    Inactive

    Thanks for all the advise and replies everyone:hattip:

    #780253
    Anonymous
    Inactive

    I load the the whole string into insert into table values (x,’http;//www.site.com’) x being id (index) then when I call the url from the html [PHP] [/PHP]This opens a new page and works fine.

Viewing 13 posts - 1 through 13 (of 13 total)