header location with id in php

0 votes

Can a row ID be passed to header()? I tried putting header() inside of an if statement, but I consistently received the following message:

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

Here's my code:

$result = mysqli_query($db_con,$query);
$target="Admin/upload/otherPic/".basename($_FILES['image']['name']);
if ($result){
    if(move_uploaded_file($_FILES['image']['tmp_name'], $target)){
        echo "<script>
            alert('Record updated successfully!');
            </script>";
        header("Location: admin-viewacc.php?id='$result['id'];'");
    }
    else{
        echo "Error updating record: " . mysqli_error($db_con);
    }
}

 

Aug 6 in PHP by Kithuzzz
• 11,040 points
72 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

Error:Cannot modify header information - headers already sent by (output started at /some/file.php:12) in /some/file.php on line 23

Hello @kartik, This error message gets triggered when anything is ...READ MORE

answered Sep 16, 2020 in PHP by Niroj
• 82,780 points
3,799 views
0 votes
1 answer

How to run process with realtime output in PHP?

Hello @kartik, This worked for me: $cmd = "ping ...READ MORE

answered Oct 20, 2020 in PHP by Niroj
• 82,780 points
1,829 views
0 votes
1 answer

How do I get the last inserted ID of a MySQL table in PHP?

Hello @kartik, If you're using PDO, use PDO::lastInsertId. If you're ...READ MORE

answered Oct 22, 2020 in PHP by Niroj
• 82,780 points
905 views
0 votes
1 answer

How to remove a child with a specific attribute, in SimpleXML for PHP?

Hii, Just unset the node: $str = <<<STR <a> ...READ MORE

answered Nov 5, 2020 in PHP by Niroj
• 82,780 points
1,869 views
0 votes
1 answer

How to find Object ID in PHP?

Hello @kartik, Use spl_object_hash() for that. It returns an unique identifier ...READ MORE

answered Nov 16, 2020 in PHP by Niroj
• 82,780 points
602 views
0 votes
1 answer

How do I resize pngs with transparency in PHP?

Hello @kartik, you need to set the blending ...READ MORE

answered Nov 23, 2020 in PHP by Niroj
• 82,780 points
722 views
0 votes
1 answer

Simple question regarding PHP, Wordpress & Yoast SEO

the way the search engine displays your ...READ MORE

answered Feb 14 in Others by narikkadan
• 18,480 points
45 views
0 votes
1 answer

How to fix "Headers already sent" error in PHP

The functions that send and modify the ...READ MORE

answered Feb 17 in Others by Aditya
• 7,660 points
942 views
0 votes
0 answers

PHP header(Location: ...): Force URL change in address bar

I have a new webpage but the ...READ MORE

Jun 1 in PHP by Kichu
• 19,040 points
368 views
0 votes
0 answers

PHP generate file for download then redirect

I have a PHP app that creates ...READ MORE

Jun 20 in PHP by narikkadan
• 18,480 points
77 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP