Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.