Jump to content

Archived

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

Mirek

header("Location:") problem

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
From the looks of what you provided (error message), the error seems to be not on this page but on message_board_view.php.

I may be wrong, but its just an idea. Maybe you would like to review your code on message_board_view.php as well?

Share this post


Link to post
Share on other sites
Display your query when you issue the mysql_error:
[code]<?php
$resulted = mysql_query($sqled) or die("There is a problem with the query: $query<br>' . mysql_error());
?>[/code]
This may make the error very apparent.

Ken

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

×

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.