Insert values into MySQL table using PHP

please delete me

I am trying to insert values into MySQL table using PHP.

PHP code:

<?php

$host = "localhost";
$user = "xcode";
$pass = "xcode";
$db = "xcode";
$r = mysql_connect($host, $user, $pass);

if (!$r) {
    echo "Could not connect to server\n";
    trigger_error(mysql_error(), E_USER_ERROR);
} else {
    echo "Connection established\n";
}

echo mysql_get_server_info() . "\n";
$r2 = mysql_select_db($db);

if (!$r2) {
    echo "Cannot select database\n";
    trigger_error(mysql_error(), E_USER_ERROR);
} else {
  echo "database selected\n";
}
$sql = "INSERT INTO name(name) VALUES('$_POST[name]')";
if (!mysql_query($sql)) {
    trigger_error(mysql_error(), E_USER_ERROR);
} else {
    echo "1 record added";
}
mysql_close();

?>

Objective-C code:

NSString *strURL = [NSString stringWithFormat:@"http://192.168.1.12:81/priya/sample.php?name=%@", txtname.text];
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
NSLog(@"%@", strResult);

I got database connection successfully, but values are not inserted. Where is the mistake?

Diwakar upadhyay

I think problem is in this line Check below line:

$sql="insert into name(name)values('{$_POST['name']}')";

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Insert values into a table with a foreign key using mysql

From Dev

How to insert checkbox values into table using PHP?

From Dev

How to insert checkbox values into table using PHP?

From Dev

Insert XML Data to MySQL Table Using PHP

From Dev

Unable to insert data in a MySQL table using PHP

From Dev

mysql insert values into table?

From Dev

How to insert two different check box values into different columns of one mysql table using php?

From Dev

How to insert sandbox Paypal return values into MySQL table using PHP Wordpress?

From Dev

Using values returned from a mysql table in PHP

From Dev

Cannot add values to table using mysql and php

From Dev

Comparing if values exists in a MySQL table using PHP

From Dev

mysql insert duplicate values into table

From Dev

mySQL - Unable to Insert Values to Table

From Dev

cannot insert values into table(mysql)

From Dev

How to insert values of dynamic fields into database using PHP ,MySqL and JQuery

From Dev

How i will stop specific keyword to insert into mysql table using php

From Dev

How to insert record into two mysql table using php?

From Dev

Insert cummulative sum in mysql table using php script

From Dev

How to insert record into two mysql table using php?

From Dev

Retrieve data from mysql database and insert it in a table using php

From Dev

insert values into table using Varray

From Dev

PHP insert the array values into mysql

From Dev

PHP INSERT boolean values into mysql

From Dev

MYSQL Insert values into another table if values not exists

From Dev

MySQL insert into table, values form another table

From Dev

searching and retrieving table values using a parameter in android using php,mysql

From Dev

Mysql insert into a table using values from the same table with increment of one in coloum

From Dev

Multiple insert in MySQL table from PHP table

From Dev

Multiple insert in MySQL table from PHP table

Related Related

  1. 1

    Insert values into a table with a foreign key using mysql

  2. 2

    How to insert checkbox values into table using PHP?

  3. 3

    How to insert checkbox values into table using PHP?

  4. 4

    Insert XML Data to MySQL Table Using PHP

  5. 5

    Unable to insert data in a MySQL table using PHP

  6. 6

    mysql insert values into table?

  7. 7

    How to insert two different check box values into different columns of one mysql table using php?

  8. 8

    How to insert sandbox Paypal return values into MySQL table using PHP Wordpress?

  9. 9

    Using values returned from a mysql table in PHP

  10. 10

    Cannot add values to table using mysql and php

  11. 11

    Comparing if values exists in a MySQL table using PHP

  12. 12

    mysql insert duplicate values into table

  13. 13

    mySQL - Unable to Insert Values to Table

  14. 14

    cannot insert values into table(mysql)

  15. 15

    How to insert values of dynamic fields into database using PHP ,MySqL and JQuery

  16. 16

    How i will stop specific keyword to insert into mysql table using php

  17. 17

    How to insert record into two mysql table using php?

  18. 18

    Insert cummulative sum in mysql table using php script

  19. 19

    How to insert record into two mysql table using php?

  20. 20

    Retrieve data from mysql database and insert it in a table using php

  21. 21

    insert values into table using Varray

  22. 22

    PHP insert the array values into mysql

  23. 23

    PHP INSERT boolean values into mysql

  24. 24

    MYSQL Insert values into another table if values not exists

  25. 25

    MySQL insert into table, values form another table

  26. 26

    searching and retrieving table values using a parameter in android using php,mysql

  27. 27

    Mysql insert into a table using values from the same table with increment of one in coloum

  28. 28

    Multiple insert in MySQL table from PHP table

  29. 29

    Multiple insert in MySQL table from PHP table

HotTag

Archive