SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2004
    Location
    Telford, UK.
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    strings in url - how to have more than one?

    I'm trying to send two strings to another webpage - when I use only one it works fine but I get a "page does not exist" error as soon as I stick another one in!! Any ideas why? How do I link the strings together in the url?!?!




    PHP Code:
     // REDIRECT 
    $url "clinician_checks2.php?pin=" $_POST['clinician_pin']&"date1=" $_POST['T1']; 
        
    header("Location: " $url); 

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $url 'clinician_checks2.php?pin=' .
        
    $_POST['clinician_pin'] .
        
    '&date1=' 
        
    $_POST['T1']; 

  3. #3
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Belgian in Mexico
    Posts
    307
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have to modify your string a little bit and use this:
    PHP Code:
    // REDIRECT 
    $url "clinician_checks2.php?pin=" $_POST['clinician_pin'] . "&date1=" $_POST['T1']; 
        
    header("Location: " $url); 
    Regards,

    MichaŽl
    MichaŽl Niessen
    http://assemblysys.com
    (Countries/states/cities with latitude & longitude,
    weathercodes & topical databases)

  4. #4
    SitePoint Zealot
    Join Date
    Dec 2004
    Location
    Telford, UK.
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Crikey, well that's really blown my mind. What do the full stops do?

  5. #5
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Belgian in Mexico
    Posts
    307
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The full stops do nothing. You just had to put the "&" sign inside the quotes

    MichaŽl
    MichaŽl Niessen
    http://assemblysys.com
    (Countries/states/cities with latitude & longitude,
    weathercodes & topical databases)

  6. #6
    Obey the Purebreed trib4lmaniac's Avatar
    Join Date
    Dec 2004
    Location
    Cornwall, UK
    Posts
    594
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mniessen
    The full stops do nothing. You just had to put the "&" sign inside the quotes

    MichaŽl
    Well, they do do something. A full-stop is the PHP concatenation operator (joins two strings together).

  7. #7
    SitePoint Zealot
    Join Date
    Dec 2004
    Location
    Telford, UK.
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right - thanks guys! Think I understand that, better still it works anyway!! Cheers!


    I have however, got another problem. I cannot get some data from the Mysql for some reason.

    This is the code that deals with it. First part is the php for getting the data from database (all connections are working). Then the second part is displaying the data. WHat is happening is that the third column is printing the same as second column for some reason?!

    PHP Code:
     // SELECT DATA FROM DATABASE

    $clin_pin $_GET['pin'];
            
    $query2="SELECT name, station FROM clinician where pin = '$clin_pin'";
    $result2=mysql_query($query2);
    $clin_name=mysql_result($result2,'name');
    $clin_station=mysql_result($result2,'station'); 
    PHP Code:
    <table border="1" width="68%">
        <tr>
          <td width="33%" align="center"><?php echo $_GET['pin'?></td>
          <td width="33%" align="center"><?php echo $clin_name ?></td>
          <td width="34%" align="center"><?php echo $clin_station ?></td>
        </tr>
      </table>

    So,
    instead of displaying

    | PA2452 | Geoff | Place Name |

    It's actually displaying

    | PA2452 | Geoff | Geoff |



    I can't see a problem in code!

  8. #8
    Obey the Purebreed trib4lmaniac's Avatar
    Join Date
    Dec 2004
    Location
    Cornwall, UK
    Posts
    594
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure the correct value is in the database (use phpMyAdmin or similar to check).

  9. #9
    SitePoint Zealot
    Join Date
    Dec 2004
    Location
    Telford, UK.
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the content of the table "clinician"

    so the info is there!! Is the code correct?


    id pin pin2 name station
    1 PA13831 TW00818 Kilvert, M Tettenhall
    2 PA02452 Geoff Yeates Wombourne
    3 PA00779 Richard Pearse Tettenhall
    4 TW00911 Ben Rhodes Tettenhall

  10. #10
    Obey the Purebreed trib4lmaniac's Avatar
    Join Date
    Dec 2004
    Location
    Cornwall, UK
    Posts
    594
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What about:
    PHP Code:
    $query2="SELECT name, station FROM clinician where pin = '$clin_pin'";
    $result2=mysql_query($query2);
    $clin=mysql_fetch_assoc($result2);
    $clin_name $clin['name'];
    $clin_station $clin['station']; 

  11. #11
    SitePoint Zealot
    Join Date
    Dec 2004
    Location
    Telford, UK.
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fantastic, that works!!! This really confuses me. What was different?

  12. #12
    Obey the Purebreed trib4lmaniac's Avatar
    Join Date
    Dec 2004
    Location
    Cornwall, UK
    Posts
    594
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just used mysql_fetch_assoc instead of mysql_result as I am more familiar with it.

    Looking at the documentation it seems you should have called mysql_result with a third parameter:
    PHP Code:
    $query2="SELECT name, station FROM clinician where pin = '$clin_pin'";
    $result2=mysql_query($query2);
    $clin_name=mysql_result($result21'name');
    $clin_station=mysql_result($result21'station'); 


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
  •