Jump to content


Photo

header("Location:") problem


  • Please log in to reply
5 replies to this topic

#1 Mirek

Mirek
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 03 June 2006 - 02:52 AM

Hi all

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

Here is my 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);

            }
    }
?>


$_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

#2 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 03 June 2006 - 04:33 AM

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");

            }
    }
?>


change the header thing you had the quotes wrong

header("Location: message_board_view.php?id=$mid"); is what it should be
"Syntax error" .. WHERE THE **** IS IT?!

#3 Mirek

Mirek
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 03 June 2006 - 05:23 AM

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

#4 seanlim

seanlim
  • Members
  • PipPipPip
  • Advanced Member
  • 355 posts
  • LocationLondon, United Kingdom

Posted 03 June 2006 - 09:41 AM

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?

#5 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 03 June 2006 - 12:20 PM

Display your query when you issue the mysql_error:
<?php
$resulted = mysql_query($sqled) or die("There is a problem with the query: $query<br>' . mysql_error());
?>
This may make the error very apparent.

Ken

#6 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 03 June 2006 - 05:14 PM

[!--quoteo(post=379554:date=Jun 3 2006, 12:23 AM:name=Mirek)--][div class=\'quotetop\']QUOTE(Mirek @ Jun 3 2006, 12:23 AM) View Post[/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
"Syntax error" .. WHERE THE **** IS IT?!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users