Entering data into MySQl database 
Author Message
 Entering data into MySQl database

Why does this simple script not work?

$test = "Earth";

$query = "INSERT INTO planet ( powers, location  ) values( 'laser',
'$test'; )";
mysql_query( $query, $link );

When I run the above script, 'laser' is entered into MySQL database but not
'Earth'.

The 'location' field has correct attributes because if I replace $test with
'Earth' then it is entered into my database.

TIA

Bundy



Mon, 01 Aug 2005 06:05:24 GMT  
 Entering data into MySQl database
Take out the semicolon after '$test'; in your query statement.

Marcus

Quote:

> Why does this simple script not work?

> $test = "Earth";

> $query = "INSERT INTO planet ( powers, location  ) values( 'laser',
> '$test'; )";
> mysql_query( $query, $link );

> When I run the above script, 'laser' is entered into MySQL database but not
> 'Earth'.

> The 'location' field has correct attributes because if I replace $test with
> 'Earth' then it is entered into my database.

> TIA

> Bundy



Mon, 01 Aug 2005 06:12:03 GMT  
 Entering data into MySQl database
Cheers

How simple was that!

Thanks you Marcus

Bundy

Quote:

> Take out the semicolon after '$test'; in your query statement.

> Marcus


> > Why does this simple script not work?

> > $test = "Earth";

> > $query = "INSERT INTO planet ( powers, location  ) values( 'laser',
> > '$test'; )";
> > mysql_query( $query, $link );

> > When I run the above script, 'laser' is entered into MySQL database but
not
> > 'Earth'.

> > The 'location' field has correct attributes because if I replace $test
with
> > 'Earth' then it is entered into my database.

> > TIA

> > Bundy



Mon, 01 Aug 2005 06:31:33 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How do I write flattened to string data to a MySQL database

2. Sending data to MySQL Database

3. Using PHP to transfer data between 2 MySQL databases

4. Translation of web entered data

5. Zoom box to enter data

6. Enter data once

7. TERM error when entering data

8. problems entering data in a field (only with NT 4)

9. Newbie Question - Entering Data into Labview program

10. adding and entering data with accents

11. Persistence of user-entered data in form

12. nl2br() on entering data or pulling it out?

 

 
Powered by phpBB® Forum Software