Jump to content

header("Location:") problem


Mirek

Recommended Posts

Hi all

I am stuck with a problem of passing a $_GET[] variable via a header line.

Here is my code ::

[code]

if( $_POST["submit"]){


    $mid = $_GET['id'];    
    $mname = $_POST['threadname'];
    $mbody = $_POST['threadbody'];
    $mtime = $_POST['threadtime'];
    

    $sqled = "INSERT INTO messagereply (threadid,replytime,replyname,replybody) VALUES ('$mid','$mtime','$mname','$mbody')";

  
                 $resulted = mysql_query($sqled) or die(mysql_error());


                  if ($resulted){

                         header("Location: message_board_view.php?id=".$mid);

            }
    }
?>

[/code]

$_GET['id'] is a variable passed from a previous page stored in $mid.

Everything works great, the query and header until I add $mid on the end of my header message where I get the following error on the target page after submiting the form::

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
[/quote]

Any help would be greatly appriciated.

Cheers
Mirek
Link to comment
https://forums.phpfreaks.com/topic/11066-headerlocation-problem/
Share on other sites

[code]if( $_POST["submit"]){


    $mid = $_GET['id'];    
    $mname = $_POST['threadname'];
    $mbody = $_POST['threadbody'];
    $mtime = $_POST['threadtime'];
    

    $sqled = "INSERT INTO messagereply (threadid,replytime,replyname,replybody) VALUES ('$mid','$mtime','$mname','$mbody')";

  
                 $resulted = mysql_query($sqled) or die(mysql_error());


                  if ($resulted){

                         header("Location: message_board_view.php?id=$mid");

            }
    }
?>[/code]


change the header thing you had the quotes wrong

header("Location: message_board_view.php?id=$mid"); is what it should be
Link to comment
https://forums.phpfreaks.com/topic/11066-headerlocation-problem/#findComment-41368
Share on other sites

[!--quoteo(post=379554:date=Jun 3 2006, 12:23 AM:name=Mirek)--][div class=\'quotetop\']QUOTE(Mirek @ Jun 3 2006, 12:23 AM) [snapback]379554[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Thx legohead6,

I have played around with quotes etc and on my Windows XP PHP/MySql set-up it works just fine but uploaded to my Apache host server it does not work. :(

Cheers
Mirek
[/quote]

ya im on apache too and thats what works for me...so it should work for you
Link to comment
https://forums.phpfreaks.com/topic/11066-headerlocation-problem/#findComment-41493
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.