PHP GET not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
satikas
Forum Newbie
Posts: 19
Joined: Sat Mar 28, 2009 9:14 am

PHP GET not working

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP GET not working

Post by requinix »

Does var_dump($_GET["picnr"]) produce

Code: Select all

string(1) "1"
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: PHP GET not working

Post by pickle »

Why do you have 2 PHP code blocks rather than 1?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply