Passing user id in the url [closed]










-5















I am trying to pass the userId in the url. This is what I have, but it giving me error.



<?php echo "<li><a href='edit.php?userId= .$row[id].'>Edit</a></li>"?>









share|improve this question













closed as off-topic by Alon Eitan, Merianos Nikos, Mohammad, Carl Binalla, Nigel Ren Nov 15 '18 at 7:17


This question appears to be off-topic. The users who voted to close gave these specific reasons:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Mohammad, Carl Binalla, Nigel Ren

  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Alon Eitan, Merianos Nikos

If this question can be reworded to fit the rules in the help center, please edit the question.
















  • Just do: ?userId=$row[id]'>. No need for the dots when your using variable interpolation. Dots are for concatenation. Here's the manual about the correct syntax Also, if you get an error, you need to tell us what error. The posted code shouldn't produce any error message by itself, though.

    – Magnus Eriksson
    Nov 15 '18 at 6:42












  • "This is what I have, but it giving me error." - What's the error?!

    – Alon Eitan
    Nov 15 '18 at 6:46











  • It's also recommended to avoid outputting HTML with PHP for multiple reasons (quote escaping/poor syntax highlighting in most IDE's/harder to find errors and debug). You could just do: <li><a href="edit.php?userId=<?= $row[id] ?>">Edit</a></li> instead.

    – Magnus Eriksson
    Nov 15 '18 at 6:49












  • @MagnusEriksson $row[id] looks funny to me, but it should throw a warning not an error AFAIK

    – Alon Eitan
    Nov 15 '18 at 6:52






  • 1





    @AlonEitan - That's true when you're not in double quoted string (or if you are but are using the complex style). When using simple variable interpolation, the syntax is slightly different. Here's an example

    – Magnus Eriksson
    Nov 15 '18 at 7:02















-5















I am trying to pass the userId in the url. This is what I have, but it giving me error.



<?php echo "<li><a href='edit.php?userId= .$row[id].'>Edit</a></li>"?>









share|improve this question













closed as off-topic by Alon Eitan, Merianos Nikos, Mohammad, Carl Binalla, Nigel Ren Nov 15 '18 at 7:17


This question appears to be off-topic. The users who voted to close gave these specific reasons:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Mohammad, Carl Binalla, Nigel Ren

  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Alon Eitan, Merianos Nikos

If this question can be reworded to fit the rules in the help center, please edit the question.
















  • Just do: ?userId=$row[id]'>. No need for the dots when your using variable interpolation. Dots are for concatenation. Here's the manual about the correct syntax Also, if you get an error, you need to tell us what error. The posted code shouldn't produce any error message by itself, though.

    – Magnus Eriksson
    Nov 15 '18 at 6:42












  • "This is what I have, but it giving me error." - What's the error?!

    – Alon Eitan
    Nov 15 '18 at 6:46











  • It's also recommended to avoid outputting HTML with PHP for multiple reasons (quote escaping/poor syntax highlighting in most IDE's/harder to find errors and debug). You could just do: <li><a href="edit.php?userId=<?= $row[id] ?>">Edit</a></li> instead.

    – Magnus Eriksson
    Nov 15 '18 at 6:49












  • @MagnusEriksson $row[id] looks funny to me, but it should throw a warning not an error AFAIK

    – Alon Eitan
    Nov 15 '18 at 6:52






  • 1





    @AlonEitan - That's true when you're not in double quoted string (or if you are but are using the complex style). When using simple variable interpolation, the syntax is slightly different. Here's an example

    – Magnus Eriksson
    Nov 15 '18 at 7:02













-5












-5








-5


1






I am trying to pass the userId in the url. This is what I have, but it giving me error.



<?php echo "<li><a href='edit.php?userId= .$row[id].'>Edit</a></li>"?>









share|improve this question














I am trying to pass the userId in the url. This is what I have, but it giving me error.



<?php echo "<li><a href='edit.php?userId= .$row[id].'>Edit</a></li>"?>






php






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 6:39









AbeAbe

14




14




closed as off-topic by Alon Eitan, Merianos Nikos, Mohammad, Carl Binalla, Nigel Ren Nov 15 '18 at 7:17


This question appears to be off-topic. The users who voted to close gave these specific reasons:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Mohammad, Carl Binalla, Nigel Ren

  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Alon Eitan, Merianos Nikos

If this question can be reworded to fit the rules in the help center, please edit the question.







closed as off-topic by Alon Eitan, Merianos Nikos, Mohammad, Carl Binalla, Nigel Ren Nov 15 '18 at 7:17


This question appears to be off-topic. The users who voted to close gave these specific reasons:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Mohammad, Carl Binalla, Nigel Ren

  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Alon Eitan, Merianos Nikos

If this question can be reworded to fit the rules in the help center, please edit the question.












  • Just do: ?userId=$row[id]'>. No need for the dots when your using variable interpolation. Dots are for concatenation. Here's the manual about the correct syntax Also, if you get an error, you need to tell us what error. The posted code shouldn't produce any error message by itself, though.

    – Magnus Eriksson
    Nov 15 '18 at 6:42












  • "This is what I have, but it giving me error." - What's the error?!

    – Alon Eitan
    Nov 15 '18 at 6:46











  • It's also recommended to avoid outputting HTML with PHP for multiple reasons (quote escaping/poor syntax highlighting in most IDE's/harder to find errors and debug). You could just do: <li><a href="edit.php?userId=<?= $row[id] ?>">Edit</a></li> instead.

    – Magnus Eriksson
    Nov 15 '18 at 6:49












  • @MagnusEriksson $row[id] looks funny to me, but it should throw a warning not an error AFAIK

    – Alon Eitan
    Nov 15 '18 at 6:52






  • 1





    @AlonEitan - That's true when you're not in double quoted string (or if you are but are using the complex style). When using simple variable interpolation, the syntax is slightly different. Here's an example

    – Magnus Eriksson
    Nov 15 '18 at 7:02

















  • Just do: ?userId=$row[id]'>. No need for the dots when your using variable interpolation. Dots are for concatenation. Here's the manual about the correct syntax Also, if you get an error, you need to tell us what error. The posted code shouldn't produce any error message by itself, though.

    – Magnus Eriksson
    Nov 15 '18 at 6:42












  • "This is what I have, but it giving me error." - What's the error?!

    – Alon Eitan
    Nov 15 '18 at 6:46











  • It's also recommended to avoid outputting HTML with PHP for multiple reasons (quote escaping/poor syntax highlighting in most IDE's/harder to find errors and debug). You could just do: <li><a href="edit.php?userId=<?= $row[id] ?>">Edit</a></li> instead.

    – Magnus Eriksson
    Nov 15 '18 at 6:49












  • @MagnusEriksson $row[id] looks funny to me, but it should throw a warning not an error AFAIK

    – Alon Eitan
    Nov 15 '18 at 6:52






  • 1





    @AlonEitan - That's true when you're not in double quoted string (or if you are but are using the complex style). When using simple variable interpolation, the syntax is slightly different. Here's an example

    – Magnus Eriksson
    Nov 15 '18 at 7:02
















Just do: ?userId=$row[id]'>. No need for the dots when your using variable interpolation. Dots are for concatenation. Here's the manual about the correct syntax Also, if you get an error, you need to tell us what error. The posted code shouldn't produce any error message by itself, though.

– Magnus Eriksson
Nov 15 '18 at 6:42






Just do: ?userId=$row[id]'>. No need for the dots when your using variable interpolation. Dots are for concatenation. Here's the manual about the correct syntax Also, if you get an error, you need to tell us what error. The posted code shouldn't produce any error message by itself, though.

– Magnus Eriksson
Nov 15 '18 at 6:42














"This is what I have, but it giving me error." - What's the error?!

– Alon Eitan
Nov 15 '18 at 6:46





"This is what I have, but it giving me error." - What's the error?!

– Alon Eitan
Nov 15 '18 at 6:46













It's also recommended to avoid outputting HTML with PHP for multiple reasons (quote escaping/poor syntax highlighting in most IDE's/harder to find errors and debug). You could just do: <li><a href="edit.php?userId=<?= $row[id] ?>">Edit</a></li> instead.

– Magnus Eriksson
Nov 15 '18 at 6:49






It's also recommended to avoid outputting HTML with PHP for multiple reasons (quote escaping/poor syntax highlighting in most IDE's/harder to find errors and debug). You could just do: <li><a href="edit.php?userId=<?= $row[id] ?>">Edit</a></li> instead.

– Magnus Eriksson
Nov 15 '18 at 6:49














@MagnusEriksson $row[id] looks funny to me, but it should throw a warning not an error AFAIK

– Alon Eitan
Nov 15 '18 at 6:52





@MagnusEriksson $row[id] looks funny to me, but it should throw a warning not an error AFAIK

– Alon Eitan
Nov 15 '18 at 6:52




1




1





@AlonEitan - That's true when you're not in double quoted string (or if you are but are using the complex style). When using simple variable interpolation, the syntax is slightly different. Here's an example

– Magnus Eriksson
Nov 15 '18 at 7:02





@AlonEitan - That's true when you're not in double quoted string (or if you are but are using the complex style). When using simple variable interpolation, the syntax is slightly different. Here's an example

– Magnus Eriksson
Nov 15 '18 at 7:02












4 Answers
4






active

oldest

votes


















3














try this:



<?php echo "<li><a href='edit.php?userId=".$row['id']."'>Edit</a></li>"?>





share|improve this answer






























    2














    You can use proper string concatenation:



    <?php echo "<li><a href='edit.php?userId=".$row['id']."'>Edit</a></li>"?>


    or wrap around the variable:



    <?php echo "<li><a href='edit.php?userId=$row['id']'>Edit</a></li>"?>





    share|improve this answer






























      1














      This one will work too:



      <?php echo "<li><a href='edit.php?userId=$row['id']'>Edit</a></li>"?>





      share|improve this answer

























      • @MagnusEriksson thankyou, that's correct!

        – Van Tho
        Nov 15 '18 at 7:09


















      -1














      just remove the concatenation before and after the parameter that you are passing in the url like this



      <?php echo "<li><a href='edit.php?userId=$row[id]'>Edit</a></li>"?> 


      or try this



      <?php echo "<li><a href='edit.php?userId='.$row[id]>Edit</a></li>"?> 





      share|improve this answer

























      • The first example would work, but the second one will not for the same reason as the OP's current code. You can't concatenate a string (using .) when you're in a double quoted string.

        – Magnus Eriksson
        Nov 15 '18 at 7:18











      • Yes, you are right. i skipped double quotes. Thanks

        – Zeeshan Tanveer
        Nov 15 '18 at 7:43

















      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      3














      try this:



      <?php echo "<li><a href='edit.php?userId=".$row['id']."'>Edit</a></li>"?>





      share|improve this answer



























        3














        try this:



        <?php echo "<li><a href='edit.php?userId=".$row['id']."'>Edit</a></li>"?>





        share|improve this answer

























          3












          3








          3







          try this:



          <?php echo "<li><a href='edit.php?userId=".$row['id']."'>Edit</a></li>"?>





          share|improve this answer













          try this:



          <?php echo "<li><a href='edit.php?userId=".$row['id']."'>Edit</a></li>"?>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 6:44









          Khalifa NikzadKhalifa Nikzad

          83213




          83213























              2














              You can use proper string concatenation:



              <?php echo "<li><a href='edit.php?userId=".$row['id']."'>Edit</a></li>"?>


              or wrap around the variable:



              <?php echo "<li><a href='edit.php?userId=$row['id']'>Edit</a></li>"?>





              share|improve this answer



























                2














                You can use proper string concatenation:



                <?php echo "<li><a href='edit.php?userId=".$row['id']."'>Edit</a></li>"?>


                or wrap around the variable:



                <?php echo "<li><a href='edit.php?userId=$row['id']'>Edit</a></li>"?>





                share|improve this answer

























                  2












                  2








                  2







                  You can use proper string concatenation:



                  <?php echo "<li><a href='edit.php?userId=".$row['id']."'>Edit</a></li>"?>


                  or wrap around the variable:



                  <?php echo "<li><a href='edit.php?userId=$row['id']'>Edit</a></li>"?>





                  share|improve this answer













                  You can use proper string concatenation:



                  <?php echo "<li><a href='edit.php?userId=".$row['id']."'>Edit</a></li>"?>


                  or wrap around the variable:



                  <?php echo "<li><a href='edit.php?userId=$row['id']'>Edit</a></li>"?>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 15 '18 at 6:56









                  Ketan YekaleKetan Yekale

                  1,27221323




                  1,27221323





















                      1














                      This one will work too:



                      <?php echo "<li><a href='edit.php?userId=$row['id']'>Edit</a></li>"?>





                      share|improve this answer

























                      • @MagnusEriksson thankyou, that's correct!

                        – Van Tho
                        Nov 15 '18 at 7:09















                      1














                      This one will work too:



                      <?php echo "<li><a href='edit.php?userId=$row['id']'>Edit</a></li>"?>





                      share|improve this answer

























                      • @MagnusEriksson thankyou, that's correct!

                        – Van Tho
                        Nov 15 '18 at 7:09













                      1












                      1








                      1







                      This one will work too:



                      <?php echo "<li><a href='edit.php?userId=$row['id']'>Edit</a></li>"?>





                      share|improve this answer















                      This one will work too:



                      <?php echo "<li><a href='edit.php?userId=$row['id']'>Edit</a></li>"?>






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Nov 15 '18 at 7:09

























                      answered Nov 15 '18 at 6:55









                      Van ThoVan Tho

                      846




                      846












                      • @MagnusEriksson thankyou, that's correct!

                        – Van Tho
                        Nov 15 '18 at 7:09

















                      • @MagnusEriksson thankyou, that's correct!

                        – Van Tho
                        Nov 15 '18 at 7:09
















                      @MagnusEriksson thankyou, that's correct!

                      – Van Tho
                      Nov 15 '18 at 7:09





                      @MagnusEriksson thankyou, that's correct!

                      – Van Tho
                      Nov 15 '18 at 7:09











                      -1














                      just remove the concatenation before and after the parameter that you are passing in the url like this



                      <?php echo "<li><a href='edit.php?userId=$row[id]'>Edit</a></li>"?> 


                      or try this



                      <?php echo "<li><a href='edit.php?userId='.$row[id]>Edit</a></li>"?> 





                      share|improve this answer

























                      • The first example would work, but the second one will not for the same reason as the OP's current code. You can't concatenate a string (using .) when you're in a double quoted string.

                        – Magnus Eriksson
                        Nov 15 '18 at 7:18











                      • Yes, you are right. i skipped double quotes. Thanks

                        – Zeeshan Tanveer
                        Nov 15 '18 at 7:43















                      -1














                      just remove the concatenation before and after the parameter that you are passing in the url like this



                      <?php echo "<li><a href='edit.php?userId=$row[id]'>Edit</a></li>"?> 


                      or try this



                      <?php echo "<li><a href='edit.php?userId='.$row[id]>Edit</a></li>"?> 





                      share|improve this answer

























                      • The first example would work, but the second one will not for the same reason as the OP's current code. You can't concatenate a string (using .) when you're in a double quoted string.

                        – Magnus Eriksson
                        Nov 15 '18 at 7:18











                      • Yes, you are right. i skipped double quotes. Thanks

                        – Zeeshan Tanveer
                        Nov 15 '18 at 7:43













                      -1












                      -1








                      -1







                      just remove the concatenation before and after the parameter that you are passing in the url like this



                      <?php echo "<li><a href='edit.php?userId=$row[id]'>Edit</a></li>"?> 


                      or try this



                      <?php echo "<li><a href='edit.php?userId='.$row[id]>Edit</a></li>"?> 





                      share|improve this answer















                      just remove the concatenation before and after the parameter that you are passing in the url like this



                      <?php echo "<li><a href='edit.php?userId=$row[id]'>Edit</a></li>"?> 


                      or try this



                      <?php echo "<li><a href='edit.php?userId='.$row[id]>Edit</a></li>"?> 






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Nov 15 '18 at 6:59

























                      answered Nov 15 '18 at 6:54









                      Zeeshan TanveerZeeshan Tanveer

                      313




                      313












                      • The first example would work, but the second one will not for the same reason as the OP's current code. You can't concatenate a string (using .) when you're in a double quoted string.

                        – Magnus Eriksson
                        Nov 15 '18 at 7:18











                      • Yes, you are right. i skipped double quotes. Thanks

                        – Zeeshan Tanveer
                        Nov 15 '18 at 7:43

















                      • The first example would work, but the second one will not for the same reason as the OP's current code. You can't concatenate a string (using .) when you're in a double quoted string.

                        – Magnus Eriksson
                        Nov 15 '18 at 7:18











                      • Yes, you are right. i skipped double quotes. Thanks

                        – Zeeshan Tanveer
                        Nov 15 '18 at 7:43
















                      The first example would work, but the second one will not for the same reason as the OP's current code. You can't concatenate a string (using .) when you're in a double quoted string.

                      – Magnus Eriksson
                      Nov 15 '18 at 7:18





                      The first example would work, but the second one will not for the same reason as the OP's current code. You can't concatenate a string (using .) when you're in a double quoted string.

                      – Magnus Eriksson
                      Nov 15 '18 at 7:18













                      Yes, you are right. i skipped double quotes. Thanks

                      – Zeeshan Tanveer
                      Nov 15 '18 at 7:43





                      Yes, you are right. i skipped double quotes. Thanks

                      – Zeeshan Tanveer
                      Nov 15 '18 at 7:43



                      這個網誌中的熱門文章

                      How to read a connectionString WITH PROVIDER in .NET Core?

                      Node.js Script on GitHub Pages or Amazon S3

                      Museum of Modern and Contemporary Art of Trento and Rovereto