Noob wants answers

$db_host = “dont mather”;
$db_username = “dont mather”;
$db_pass = “dont mather”;
$db_name = “dont mather”;

@mysql_connect(“$db_host”,“$db_username”,“$db_pass”) or die (“kommer inte åt mysql”);
@mysql_select_db(“$db_name”) or die (“kommer inte åt databas”);

echo (“it works”);

if( isset($_post[‘förnamn’],$_post[‘efternamn’],$_post[‘ålder’]) )

mysql_query(“insert into tommy set
förnamn = ‘{$_post[‘förnamn’]}’,
efternamn = ‘{$_post[‘efternamn’]}’,
ålder = ‘{$_post[‘ålder’]}’”)

<from action=“” method=“get”>
<input type=“text” name=“förnamn” /><br />
<input type=“text” name=“efternamn” /><br />
<input type=“text” name=“ålder” /><br />
<input type=“submit” value=“post” />

The text (it works shows up so that is not the problem).

I cant get the data to my database. Watched this video but it still doesn’t work. YouTube - ‪PHP Tutorials: MySQL Basics (Part 3/6)‬‏

(phpmyadmin) when i click on tommy then (id,förnamn,efternamn,ålder) shows upp.

It should be this format:

insert into <table name> (column name, column name> values <‘value’, ‘value’)

The OP’s format is fine too: MySQL :: MySQL 5.5 Reference Manual :: 12.2.5 INSERT Syntax (see format #2)

The first error I notice is that the form method is GET, and in the php code you use $_POST. Change the method to POST, or use $_GET in the php code.

also note that $_post is not the same as $_POST.

As well as the previous comments …

using this instead of echo would tell you a lot more:

var_dump( $_POST);

Also, you probably have this working, but using chars like this for field names mean you must always remember to escape them with backticks `

For that reason I’d avoid using å - but it is quite up to you.

Try this:

if(isset($_POST['förnamn'], $_POST['efternamn'], $_POST['ålder'])) {
    mysql_query("INSERT `tommy` SET
        `förnamn` = '" . mysql_real_escape_string($_post['förnamn']) . "',
        `efternamn` = '" . mysql_real_escape_string($_POST['efternamn']) . "',
        `ålder` = '" . mysql_real_escape_string($_POST['ålder'] . "'");
    if (mysql_errno()) { 

If an error has occured, it will display it.
I also added some simple code to escape your data before it is inserted, to stop bad people from destroying your database by sending bad data. :slight_smile: