1

Have you copied the displayed SQL into phpmyadmin and tested it there? And is the ID correct one?

0

i do not know how to do it, and id is correct one, shall i show the screenshot of phpmyadmin?

Attachments mysqldb.png 16.69 KB
1

Sometimes you do not see a forest because of the trees :-). There is a very nice reply on SO:

I dont see where you are executing your UPDATE STATEMENT.

In fact, the query seems to be OK, but you are not executing it. This very important part of the code is missing:

$result = mysql_query($sql);

Put it instead of the die (debug) statement.

0

still, nothing is changed, i did as you mentioned, but DB is not being updated, instead it is keeping older values in DB and taking them to the page. :(

1

i do not know how to do it, and id is correct one, shall i show the screenshot of phpmyadmin?

In phpmyadmin select the database, click on the SQL tab and paste the query (displayed by the die statement) into the textarea. Click the Go button and the query will execute on your database. If there are errors in the query phpmyadmin will tell you.

0

do i have to paste this there, in phpmyadmin?

UPDATE db_purchase_form SET db_product_name = 'Video Message 1', db_actor = 'bride', db_user_name = 'dfdfdfd', db_user_email = 'fghgfh@fff.vom', db_vdo_script = 'later', db_hrt_msg = '', db_port_approval = 'yes', db_delivery = 'express', db_price = '41.94', db_date_time = NOW() WHERE id = '54'

0

okay when i run this in phpmyadmin, it says, 1 row affected and it updated that row. Seems it worked in phpmyadmin. Why not on page? Now what?

0

okay i did some change in the code,

if ($has_data == true)
        {
            $sql  = "UPDATE db_purchase_form SET ";
            $sql .= "db_product_name = '" . $product_name . "', ";
            $sql .= "db_actor = '" . $choice_actor . "', ";
            $sql .= "db_user_name = '" . $user_name . "', ";
            $sql .= "db_user_email = '" . $user_email . "', ";
            $sql .= "db_vdo_script = '" . $vdo_script . "', ";
            $sql .= "db_hrt_msg = '" . $hrt_msg . "', ";
            $sql .= "db_port_approval = '" . $portApproval . "', ";
            $sql .= "db_delivery = '" . $delivery . "', ";
            $sql .= "db_price = '" . $net_price . "', ";
            $sql .= "db_date_time = NOW() ";
            $sql .= "WHERE id = '{$id}'";
            $result_update = mysql_query($sql);
            if($result_update)
                {
                    echo("<br>Input data is succeed");
                }
                else
                {
                    $message = "The data cannot be inserted.";
                    $message .= "<br />" . mysql_error();
                }

and when i run it, trying to update the page, the output was
"Input data is succeed"

but the DB is not updated of new values, wtf is happening?

1

We have to find out why the app can not update the table. Change the code to this:

if ($has_data == true)
{
    $sql = "UPDATE db_purchase_form SET ";
    $sql .= "db_product_name = '" . $product_name . "', ";
    $sql .= "db_actor = '" . $choice_actor . "', ";
    $sql .= "db_user_name = '" . $user_name . "', ";
    $sql .= "db_user_email = '" . $user_email . "', ";
    $sql .= "db_vdo_script = '" . $vdo_script . "', ";
    $sql .= "db_hrt_msg = '" . $hrt_msg . "', ";
    $sql .= "db_port_approval = '" . $portApproval . "', ";
    $sql .= "db_delivery = '" . $delivery . "', ";
    $sql .= "db_price = '" . $net_price . "', ";
    $sql .= "db_date_time = NOW() ";
    $sql .= "WHERE id = '{$id}'";

    $result = mysql_query($sql);

    // debug code
    if($result == true) {
        $msg = 'Query executed successfully:' . $sql;
    } else {
        $msg = 'Query did not execute successfully: ' . mysql_error(); 
    }
    die($msg);
    //end debug code
}

Post the output here.

Edited by broj1

1

OK, you were too fast for me. Next thing we can do is you post the last version of the scripts and the tables in question (structure and data). I can try to recreate the problem here in my environment. If you post the table do it in a SQL form. Make sure confidental data is anonymized.

Edited by broj1

0

Query executed successfully:UPDATE db_purchase_form SET db_product_name = 'Video Message 1', db_actor = 'bride', db_user_name = 'ghfghfg', db_user_email = 'fghgfh@fff.vom', db_vdo_script = ' fg gg fg fg f fgh g f', db_hrt_msg = '', db_port_approval = 'yes', db_delivery = 'express', db_price = '41.94', db_date_time = NOW() WHERE id = '57'

but this is not the data i changed on the page. This is the earlier data in the DB. This means, somehow newer data is not sustained, or is being lost, but where?

this data is generated using your code, i removed mine.

Also the lines you wrote above
"Next thing we can do is you post the last version of the scripts and the tables in question (structure and data). I can try to recreate the problem here in my environment. If you post the table do it in a SQL form. Make sure confidental data is anonymized."

can you explain in simple english? what am i supposed to do?
Thx

Edited by Swati_2: Addition

0

what i understand from your earlier post is do you want me to post the files or code here?

1

Post the latest version of the scripts that are involved and the structure of the tables and data in a SQL format (export from phpmyadmin) for all the tables that are mentioned in queries. I will import the tables and data into my test database and try to run scripts on my local server. This is the only thing that comes to my mind to help you find the solution to the problem.

To export the tables structure and data in SQL format select the table in phpmyadmin, click on the export tab, leave all options default and click Go. You will be able to save the SQL statement (describing table structure and data) on your local machine. Do this for all tables in question and send everything as an attachment. I will do import (in phpmyadmin) and test the scripts in my environment.

If you are uncomfortable doing this you do not have to. Also if you prefer you can send all this as a personal message to me here on DW.

Edited by broj1

0

Hii, it seems that in i am not authorized to send PM. But i can do it by replying to one received.

So instead you send me pm and i will reply to the same attaching the latest scripts.

Also i upvoted all your posts here. Hope it helps.

Thanks

0

i have a thought in the mind....

the problem is in this code

$id = 0;
    if (isset($_GET['id']) && ($_GET['id'] != ''))
    {
        $id = (int)htmlspecialchars($_GET['id']);
    }
    $query  = "SELECT * from db_purchase_form where id = $id";
    $result = mysql_query($query);
    $has_data = false;
    while($row = mysql_fetch_row($result))
    {
        $has_data = true;
        $product_name = $row[1];
        $choice_actor = $row[2];
        $user_name = $row[3];
        $user_email = $row[4];
        $vdo_script = $row[5];
        $hrt_msg = $row[6];
        $portApproval = $row[7];
        $delivery = $row[8];
        $net_price = $row[9];
    }
    if(isset($_POST['submit']))
    {
        if ($has_data == true)
        {
            $sql = "UPDATE db_purchase_form SET ";
            $sql .= "db_product_name = '" . $product_name . "', ";
            $sql .= "db_actor = '" . $choice_actor . "', ";
            $sql .= "db_user_name = '" . $user_name . "', ";
            $sql .= "db_user_email = '" . $user_email . "', ";
            $sql .= "db_vdo_script = '" . $vdo_script . "', ";
            $sql .= "db_hrt_msg = '" . $hrt_msg . "', ";
            $sql .= "db_port_approval = '" . $portApproval . "', ";
            $sql .= "db_delivery = '" . $delivery . "', ";
            $sql .= "db_price = '" . $net_price . "', ";
            $sql .= "db_date_time = NOW() ";
            $sql .= "WHERE id = '{$id}'";
            $result = mysql_query($sql);
            // debug code
            if($result)
            {
                //echo("<br>Input data is succeed");
                //$lastInsertedId =  mysql_insert_id();
                $timestamp = time();
                header('Location:purchase_form1_conf.php?'.http_build_query(array('id' => $id,'time' => $timestamp,'hash' => sha1('some-generated-key'.$timestamp.$id))));
            }

what i think is, that when we submit the data by clicking submit not the id

<form id="PurchaseForm" name="PurchaseForm" method="post" action="purchase_form1.php?id=<?php echo $id;?>">

(set in the purchaseform) is somehow preventing the new updated code to be inserted in the DB. This is what i think, what do you say?

1

Quite possible. But it is hard to tell just by looking at the snippet of code. Maybe you should store the I'd in a hidden field so it Would be available through the POST array.

0

it is solved. Thanks a lot for all your help. If you are not here, i could have not gone through this. Is is possible i can talk to you somewhere else?

Thanks

1

Great. What have you done to solve it? Otherwise I am in central europe (quite far from India :-).

0

actually i have an other issue and i need your help to solve it.

regarding earlier, means how i solved it, i now checked for the GET id, just before submitting into DB.

and it solved it.

Also is it possible to talk ony other place, like skype? or do i have to paste the entire code here again? mine id there is erashis, whats urs?

1

If the other issue is not related then please mark this thread as solved and start a new one.

The nature of the forum is such that all memebers see the topic and the ones that have time try to help. Everyone gains by learnig solutions to various problems. This is why I would prefer that we carry on through the forum not on skype. I do not have much time to offer you a full time assistance and also am on a 3G connection most of the time (limited bandwith and traffic) so Skype is not my favourite way of communication.

So try to describe the problem as clearly as possible, post the relevant code and help will come sooner or later.

0

sure that is again not a issue. just i request you to kindle send me a private message here, so that i can reply you when i need you, and you can see that too. I will mark it completed.
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.