Wrox Programmer Forums
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL 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, 08:12 PM
Authorized User
 
Join Date: Apr 2004
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to junemo
Default

I find the solution.

Thanks all.

 
Old June 10th, 2004, 08:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

If you dont mind could you post here about the solution you found to solve that?

Cheers!

_________________________
-Vijay G
Strive for Perfection
 
Old June 10th, 2004, 09:12 PM
Authorized User
 
Join Date: Apr 2004
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to junemo
Default

<?php
$db_name = "prod";
//create connection
$conn = mysql_connect("localhost", "phpuser","") or die (mysql_error());

//select dbase
$db = mysql_select_db($db_name, $conn) or die (mysql_error());

//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= '$_POST[prod_id]'";

$result = mysql_query($sql, $conn) or die(mysql_error());
mysql_close($conn);
?>
<html>
.......

<?php
//Display all updated record
//query
$sql = "SELECT * FROM product WHERE prod_id = '$prod_id'";
$result = mysql_query($sql, $connection) or die (mysql_error());

//function
    function check(&$var)
    {
        return (isset($var))? $var :'';
    }
//refer my previous post
?>
......
</html>

It can use single QUOTEs because data type set as VARCHAR (prod_id). Isn't?
I use function check(&$var) to assign the values of $_POST variables.(Thanks Rich)

Thanks for help.



 
Old June 10th, 2004, 09:20 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes, you can always you single QUOTEs around it when its type is varchar.

I actually wanted to know what you were missing so that the database was not updated, but still you were saying the UPDATE worked fine.

Is that you were missing this part earlier? as I was able to see only part of you code in all you previous post.
Code:
$sql = "SELECT * FROM product WHERE prod_id = '$prod_id'";
Cheers!

_________________________
-Vijay G
Strive for Perfection
 
Old June 10th, 2004, 10:11 PM
Authorized User
 
Join Date: Apr 2004
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to junemo
Default

Before I say UPDATE worked fine because I had test on mysql.exe, it can function. But at html form, must use $_POST to pass the value, isn't?
Then, I not using the POST passed the new value to dbase(UPDATE query)at my previous post.
UPDATE value can view on page may be because I use POST (//function)to retrieval the data from html form.

$sql = "SELECT * FROM product WHERE prod_id = '$prod_id'";
This query for me make sure I retrieving data from dbase not from previous page.

Thanks. :-)







Similar Threads
Thread Thread Starter Forum Replies Last Post
Mysql query...Pls help me raaj MySQL 2 March 17th, 2007 12:43 AM
MySQL syntax in query Tachyon Beginning PHP 1 June 26th, 2004 08:42 PM
Impossible MySQL Query? mrcornelia SQL Language 4 November 18th, 2003 03:08 AM
Random MySQL Query cmiller Beginning PHP 5 November 18th, 2003 12:44 AM
MySQL Query Problem cmiller Beginning PHP 4 August 26th, 2003 12:43 AM





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