Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 10th, 2004, 03:54 AM
Authorized User
 
Join Date: Apr 2004
Location: malacca, malacca, Malaysia.
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to junemo
Default Mysql-variable

Dear Rich,

I have SQL query to upadate new data in dbase.
I have follow your script using function check (&$var)to initialize the variable and print these variable's value.

The problem is the page can get and display the updated values BUT dbase does not UPDATE the value. It still store the old value. That mean the update is not successful! :(

So, what's the problem?

Attach code:

<?php
.....
//Formulate and execute the query
$sql = "UPDATE product SET
    prod_id= '$_POST[prod_id]',
    b_type= '$_POST[b_type]',
    descp=' $_POST[descp]',
    cust_id= '$_POST[cust_id]',
    person= '$_POST[person]',
    mod= '$_POST[mod]'
    WHERE prod_id= '$pro_id'";
....
?>

<?php
....
//query
$sql = "SELECT * FROM product WHERE prod_id = '$prod_id'";
.....

//function

    function check(&$var)
    {
        return (isset($var))? $var :'';
    }

    echo" <br><b>\n".
        " ".check($_POST['prod_id'])."\n".
        " </b>\n".
        " - The product has been updated to the database.\n".
        " <p> </p>\n".
        " <table width='45%' border='1'>\n".
        " <tr>\n".
        " <td>\n".
        " <b>Product ID:\n".
        " </td>\n".
        " <td>\n".
        " ".check($_POST['prod_id'])."\n".
        " </td>\n".
        " </tr>\n".
        " <tr>\n".
        " <td>\n".
        " <b>Board Type:\n".
        " </td>\n".
        " <td>\n".
        " ".check($_POST['b_type'])."\n".
        " </td>\n".
        " </tr>\n".
        " <tr>\n".
        " <td>\n".
        " <b>Description:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;\n".
        " </td>\n".
        " <td>\n";
?>
             <textarea name='descp' cols='80' rows='5' id='desc'><? echo "".check($_POST['descp'])."\n"; ?></textarea>

<?php
     echo " </td>\n".
        " </tr>\n".
        " <tr>\n".
        " <td>\n".
        " <b>Customer ID:\n".
        " </td>\n".
        " <td>\n".
        " ".check($_POST['cust_id'])."\n".
        " </td>\n".
        " </tr>\n".
        " <tr>\n".
        " <td>\n".
        " <b>Last Person:\n".
        " </td>\n".
        " <td>\n".
        " ".check($_POST['person'])."\n".
        " </td>\n".
        " </tr>\n".
        " <tr>\n".
        " <td>\n".
        " <b>Last Modified:\n".
        " </td>\n".
        " <td>\n".
        " ".check($_POST['mod'])."\n".
        " </td>\n".
        " </tr>\n".
        " </table>\n";


?>

Thanks in advance.






Similar Threads
Thread Thread Starter Forum Replies Last Post
ASSIGNING A JAVA SCRIPT VARIABLE TO A XSL VARIABLE SOMANATHAN10 XSLT 1 February 21st, 2007 04:26 AM
object variable or with block variable not set Aoude BOOK: Beginning VB.NET Databases 1 February 24th, 2006 05:21 PM
Object variable or With block variable not set tparrish Pro VB Databases 1 May 25th, 2005 02:08 PM
Object variable or With block variable not set tparrish VB Databases Basics 1 May 25th, 2005 10:25 AM
Variable naming in Beginning PHP, Apache, MySQL We richard.york Forum and Wrox.com Feedback 0 April 12th, 2004 07:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.