simple php question

Discussion in 'PHP' started by baris22, Jan 9, 2008.

  1. #1
    Hello all.

    Originally I have got this:

    <a href=\"musicvideo.php?vid=".$row['uniq_id']."\">".$row['video_title']."</a>
    
    
    PHP:
    and on musicvideo.php

    
    $unique_id = magicSlashes($_GET['vid']);
    
    if(!empty($unique_id) && strlen($unique_id) < '10') {
    
    $get_vid = mysql_query("SELECT * FROM pm_videos WHERE uniq_id = '".$unique_id."'");
    $get_vid = mysql_fetch_array($get_vid);
    
    
    PHP:
    Now I want to add

    
    .$row['video_title'].
    
    PHP:
    after
    vid=".$row['uniq_id']."
    PHP:
    so the link can be
    musicvideo.php?vid=0111-titleof the video

    I did like this:
    
    <a href=\"musicvideo.php?vid=".$row['uniq_id']."-".$row['video_title']."\">".$row['video_title']."</a>
    
    PHP:
    url looks ok on the listing page but does not work.
    Do i need to do anything on musicvideo.php
    
    $unique_id = magicSlashes($_GET['vid']);
    
    if(!empty($unique_id) && strlen($unique_id) < '10') {
    
    $get_vid = mysql_query("SELECT * FROM pm_videos WHERE uniq_id = '".$unique_id."'");
    $get_vid = mysql_fetch_array($get_vid);
    
    
    PHP:
    Thank you very much
     
    baris22, Jan 9, 2008 IP
  2. lfhost

    lfhost Peon

    Messages:
    232
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you might want to use either

    
    <a href=\"musicvideo.php?vid=".$row['uniq_id']."&title=".$row['video_title']."\">".$row['video_title']."</a> 
    Code (markup):
    or use intval() around the ID that is being passed.
    $unique_id = magicSlashes(intval($_GET['vid']));
    Code (markup):
    Why you would want to do the title and ID together I dont know.
     
    lfhost, Jan 9, 2008 IP
  3. 2slick

    2slick Peon

    Messages:
    73
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    if you are expecting an integer
    
    $unique_id=sprintf('%d',$_GET['vid']);
    
    Code (php):
    if it is a string or character

    
    <a href=\"musicvideo.php?vid=".$row['uniq_id']."&t=".$row['video_title']."\">".$row['video_title']."</a> 
    
    
    Code (php):
     
    2slick, Jan 9, 2008 IP
  4. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #4
    I am trying to learn seo.
     
    baris22, Jan 10, 2008 IP
  5. Kieran.in

    Kieran.in Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Uh, you might want to be looking at mod_rewrite. Really, thats not going to make a lot of difference.
     
    Kieran.in, Jan 10, 2008 IP
  6. lfhost

    lfhost Peon

    Messages:
    232
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Then this is not what you want, as said above, read up on mod rewrite. You looking to have either subfolders or clean .html pages.

    i.e.

    instead of

    <a href=\"musicvideo.php?vid=".$row['uniq_id']."&title=".$row['video_title']."\">".$row['video_title']."</a>
    Code (markup):
    you would have
    (musicvideo/1/Videoname/)
    <a href=\"musicvideo/".$row['uniq_id']."/".$row['video_title']."/\">".$row['video_title']."</a>
    Code (markup):
    or
    (musicvideo/1/Videoname.html)
    <a href=\"musicvideo/".$row['uniq_id']."/".$row['video_title'].".html\">".$row['video_title']."</a>
    Code (markup):
    you would need .htaccess entries to manage these values (you will understand this when you read up on Mod Rewrite.
     
    lfhost, Jan 10, 2008 IP