Problem in inserting

Hello,
Whenever I start a new project, I am sometimes perplexed in data processing.

I am, actually, dumping the old project and start a new project again.
Dumping and Starting again several times…

[b]myTable[/b]

n
10


I have “myTable” like the above.
The table has just one column named “n”.
The table has just one record.
The record has a numeric value “10” for the column “n”.

[b]code[/b]

<?php
$query="select n 
from myTable";
$sql=mysql_query($query);
$row=mysql_fetch_assoc($sql);

$mysql_query=("INSERT INTO myTable ( n ) VALUES ( 20 ) "); 

exit([COLOR="#FF0000"]$row['n'][/COLOR]);

 ?>

[b]result[/b]

10



I have the PHP code above in one of my pages.

DB connection code is before the code above.

The browsing result of the code above is “10”.
That means DB connection is correctly working.
But the data “20” for the column “n” is not inserted.

What’s the problem in my data inserting code above ?
Why is the data “20” not inserted (in your thinking or guessing) ?
How can I insert the data “20” to myTable?

I am in perplexed at the moment.

you assigned a string consisting of an sql query to a php variable

you never executed it

Would you please rephrase it?

How can I execute it? (I used to successfully insert the data with the code above in the old project.)

here, you assign a value to a variable –

$query="select n 
from myTable";

here, you execute it –

$sql=[COLOR="#FF0000"]mysql_query([/COLOR]$query[COLOR="#FF0000"])[/COLOR];

here, you assign a value to another variable –

$mysql_query=("INSERT INTO myTable ( n ) VALUES ( 20 ) "); 

but then you forgot to execute it

something like that
$result = mysql_query("INSERT INTO myTable ( n ) VALUES ( 20 ) ")

$query=("INSERT INTO myTable ( n ) VALUES ( 20 ) ");
$sql=mysql_query($query);

With the code above, I’ve succeeded inserting the data.
Anyway, the problem is solved.
I am still wonder that why the data is successfully inserted in the old project without the execution “$sql=mysql_query($query);”.