Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2003
    Posts
    42

    Apache/php/mysql problem

    Hello

    I have installed an apache v. 1.3.29 with php 4.3.4 and mysql 3.22 on my pc with win98 in order to test some scripts and I got a problem. I can`t pass variables from my browser to a php script. something goes wrong. i tested it on my host but it works fine.
    I even wrote a very simple script in order to test it but still nothing
    Here is the code:
    ---
    index.htm
    ---
    <form action="process.php" method="post">
    <input type="text" name="txt1"><br>
    <input type="submit" name="btn1">
    </form>

    (first i created a mysql database named "test" with a table named table1 and a column named "sqtest" which is a VARCHAR(20)
    ---
    process.php
    ---
    <?
    mysql_connect("localhost", "", "") or
    die("cannot connect");
    mysql_selectdb("test") or
    die("cannot select db");

    $query="INSERT INTO table1(sqtest) VALUES ('$txt1')"

    mysql_query($query) or
    die("error");
    ?>
    ---
    when i execute this starting from index.htm and check the database, the entry is creted blank. so I put to the beggining of process.php this line:
    echo($txt1);
    but the result is just nothing which means the $txt1 variable is blank. What`s wrong? Its for sure not in my code cause as i said i tested it on my host and it works.
    The problem is that it doesn`t pass the value of the "txt1" text box to the process.php script. any ideas?

    sorry for my bad English.

  2. #2
    Join Date
    Dec 2003
    Location
    Tampa Area FL
    Posts
    27
    the problem is your host is probably running an older version of PHP or has register_globals enabled, in later version of PHP it was turned off do to alot of security concerns use the global arrays instead

    $_POST['txt1'] if form method is post
    $_GET['txt1'] of sent via get.
    Erik S.
    Developer / Owner

  3. #3
    Join Date
    Sep 2003
    Location
    London, UK
    Posts
    188
    You can edit your php.ini file to reflect your hosts setup if you want just change REGISTER_GLOBALS
    It should be in c:\windows

    Rob.

  4. #4
    Join Date
    Dec 2002
    Location
    The Shadows
    Posts
    2,901
    You should actually use something like:

    $txt = ( $HTTP_POST_VARS['txt1'] ) ? $HTTP_POST_VARS['txt1'] : $_POST['txt1'];
    Dan Sheppard ~ Freelance whatever

  5. #5
    Join Date
    Jul 2003
    Location
    East TN
    Posts
    568
    Try to remember the
    Code:
     AND
    tags when posting code.

    PS Just posted so a MOD wouldn't have to....
    Take care,
    Lori
    -- Please use tags for code. PM me for information if not sure how to do so. | Refer to PHP Manual and MySQL Manual before posting.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •