Mirek Posted June 3, 2006 Share Posted June 3, 2006 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.CheersMirek Quote Link to comment https://forums.phpfreaks.com/topic/11066-headerlocation-problem/ Share on other sites More sharing options...
legohead6 Posted June 3, 2006 Share Posted June 3, 2006 [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 wrongheader("Location: message_board_view.php?id=$mid"); is what it should be Quote Link to comment https://forums.phpfreaks.com/topic/11066-headerlocation-problem/#findComment-41368 Share on other sites More sharing options...
Mirek Posted June 3, 2006 Author Share Posted June 3, 2006 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. :(CheersMirek Quote Link to comment https://forums.phpfreaks.com/topic/11066-headerlocation-problem/#findComment-41385 Share on other sites More sharing options...
seanlim Posted June 3, 2006 Share Posted June 3, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/11066-headerlocation-problem/#findComment-41415 Share on other sites More sharing options...
kenrbnsn Posted June 3, 2006 Share Posted June 3, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/11066-headerlocation-problem/#findComment-41431 Share on other sites More sharing options...
legohead6 Posted June 3, 2006 Share Posted June 3, 2006 [!--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. :(CheersMirek[/quote]ya im on apache too and thats what works for me...so it should work for you Quote Link to comment https://forums.phpfreaks.com/topic/11066-headerlocation-problem/#findComment-41493 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.