Passing user id in the url [closed]
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
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
|
show 2 more comments
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
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
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
|
show 2 more comments
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
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
php
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
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
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
|
show 2 more comments
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
|
show 2 more comments
4 Answers
4
active
oldest
votes
try this:
<?php echo "<li><a href='edit.php?userId=".$row['id']."'>Edit</a></li>"?>
add a comment |
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>"?>
add a comment |
This one will work too:
<?php echo "<li><a href='edit.php?userId=$row['id']'>Edit</a></li>"?>
@MagnusEriksson thankyou, that's correct!
– Van Tho
Nov 15 '18 at 7:09
add a comment |
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>"?>
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
add a comment |
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
try this:
<?php echo "<li><a href='edit.php?userId=".$row['id']."'>Edit</a></li>"?>
add a comment |
try this:
<?php echo "<li><a href='edit.php?userId=".$row['id']."'>Edit</a></li>"?>
add a comment |
try this:
<?php echo "<li><a href='edit.php?userId=".$row['id']."'>Edit</a></li>"?>
try this:
<?php echo "<li><a href='edit.php?userId=".$row['id']."'>Edit</a></li>"?>
answered Nov 15 '18 at 6:44
Khalifa NikzadKhalifa Nikzad
83213
83213
add a comment |
add a comment |
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>"?>
add a comment |
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>"?>
add a comment |
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>"?>
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>"?>
answered Nov 15 '18 at 6:56
Ketan YekaleKetan Yekale
1,27221323
1,27221323
add a comment |
add a comment |
This one will work too:
<?php echo "<li><a href='edit.php?userId=$row['id']'>Edit</a></li>"?>
@MagnusEriksson thankyou, that's correct!
– Van Tho
Nov 15 '18 at 7:09
add a comment |
This one will work too:
<?php echo "<li><a href='edit.php?userId=$row['id']'>Edit</a></li>"?>
@MagnusEriksson thankyou, that's correct!
– Van Tho
Nov 15 '18 at 7:09
add a comment |
This one will work too:
<?php echo "<li><a href='edit.php?userId=$row['id']'>Edit</a></li>"?>
This one will work too:
<?php echo "<li><a href='edit.php?userId=$row['id']'>Edit</a></li>"?>
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
add a comment |
@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
add a comment |
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>"?>
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
add a comment |
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>"?>
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
add a comment |
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>"?>
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>"?>
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
add a comment |
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
add a comment |
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