Hi,
below code gives me error in line 8.

1. i had paymentform.php
where i entered data.

2. below is paymentinsert.php where i am getting error in line 8.


Fatal error: Function name must be a string in /home/content/59/8390659/html/COUPONDISCOUNTS/php/MySQL/paymentinsert.php on line 8

<?
$username="aaa";
$password="bbb";
$database="aaa";
$amount=$_POST['amount'];
$description=$_POST['description'];
$sender=$_POST['sender'];
$mysql_connect("host",$aaa,$bbb);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO payment VALUES ('$amount','$description','$sender')";
mysql_query($query);

     
    if(1 === mysql_affected_rows()){
        echo 'insert passed';
        $to = "hhh@email.com";
        $subject = "New Cowboy!";
        $body = "Your data was inserted into the DB correctly!";
        if (mail($to, $subject, $body)) {
           echo("<p>Message successfully sent!</p>");
        } else {
        echo("<p>Message delivery failed...</p>");
        }
    }
    else
    echo 'insert failed';
    mysql_close();
?>

Pls advise.

Thx.

Remove the $ in front of mysql_connect.

thanks. it worked.

Another question, when record is inserted i want paymentID is incremented by 1 automatically. I have the table as below. How can i change the code below so when record is inserted into the table, paymentID gets incremented by 1.

i guess i have to add primary key and auto increment?

CREATE TABLE payment(
paymentID int,
amount int,
description varchar( 100 ) ,
Sender varchar( 50 )
)

Thanks.

You guessed right.

how do i add it?

i was able to add pk and auto increment.

First i set autoincrement to 500
then inserted some values up to 504. it worked.

then i reset auto increment to 14, but it does not work. it still increments from 505.

How can i drop any values from 500 and start increment from 14? do i have to drop old auto_increment first? not sure.

thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.