Page 1 of 1

PHP GET not working

Posted: Tue Apr 14, 2009 1:13 pm
by satikas
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Code: Select all

 
<?php require_once "../dbcon.php";
echo $_GET["picnr"]; ?>
<?php if (isset($_POST['define_url'])) {
    $result = mysql_query("INSERT INTO booklinks (username, picnr, url) 
VALUES ('".$_COOKIE['username']."', '".$_GET["picnr"]."', '".$_POST['href']."')");
header("Location: ../engine_bookmarks/edit_books_index.php");
} ?>
 
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="href" maxlength="1000">
<input type="submit" name="define_url" value="Määra">
</form>
 
The weird thing about this code is that echoing variable $_GET["picnr"] results in 1. Which is what i want. But after inserting it into the DB i see 0 as the inserted value. I did the echoing part just to know if the value is there.
Helpz :banghead:


pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Re: PHP GET not working

Posted: Tue Apr 14, 2009 2:02 pm
by requinix
Does var_dump($_GET["picnr"]) produce

Code: Select all

string(1) "1"

Re: PHP GET not working

Posted: Tue Apr 14, 2009 2:12 pm
by pickle
Why do you have 2 PHP code blocks rather than 1?