Mecnun wrote:
> I'm usin php, apache and mysql on my computer. I have run some scripts. so
> i'm sure i installed them correctly. One of my script don't run properly,
> also it doesnt give error.
> I'm trying to send some data to my database by using a form. The database
> can get the auto incremented number but doesn't get whatever I type into
> the text box in the form. My code is below:
> ------------------------------------------------------
> <?php
> //open the connection
> $conn = mysql_connect("localhost", "selimatmaca", "BETULBETUL");

If this is your real database username/password, go change it immediately!

You've just given your password to a billion people.

Also change any other accounts that use this password.

> //pick the database to use
> mysql_select_db("testDB", $conn);
> //create the sql statement
> $sql = "INSERT INTO testTable values ('', '$_POST[testField]')";
> //execute
> if (mysql_query($sql,$conn)){
> echo "Record Added";
> } else{
> echo "Somethin went wrong";
> }
> ?>

Which of these two messages do you see?

If it is 'Somethin went wrong' then you need to get more info about WHAT
went wrong.

Perhaps add:
echo mysql_error($conn);

Actually, better would be to add:
error_log(@mysql_error($conn));
and check your Apache error log file for the message.
http://php.net/error_log

> --------------------------------------------------------------
>
>
> mysql> select * from testTable;
> +----+--------------+
> | id | testField    |
> +----+--------------+
> |  1 | some value   |
> |  2 | some value   |
> |  3 |                    |
> |  4 |                    |
> |  5 |                    |
> |  6 |                    |
> |  7 |                    |
> |  8 |                    |
> |  9 |  [testField]    |
> | 10 | [testField]    |
> | 11 |                    |
> | 12 |                    |
> | 13 |                    |
> | 14 |                    |
> +----+--------------+
> 14 rows in set (0.00 sec)
>
>
> The database dont show the "testField" data, but it shows the numbers.

I'm seeing '[testField]' in there, which would indicate maybe you left out
$_POST for awhile...

Are you re-typing your source code here?  Or did you really copy/paste
your actual code?

What you have here looks okay to me...

But if that's not actually the code you are using...

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to