0

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.

Edited by Ezzaral: Added code tags - again! Learn to use them!

2
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by bangla
0

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.

Edited by Ezzaral: Added code tags. This is the last time I will add them.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.