Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
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 December 19th, 2004, 11:48 PM
Registered User
 
Join Date: Dec 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Updating Database Problem

Hi, I've been having quite a bit of trouble figuring out why my database is not being updated as a result of the following code:

<?php
    /* Updates any information in that has been altered
    by the user via the Edit option */

    $NAME=$_POST['updateNAME'];
    $MAC=$_POST['updateMAC'];
    $IP=$_POST['updateIP'];
    $LOCATION=$_POST['updateLOCATION'];
    $VIRUS=$_POST['updateVIRUS'];
    $VERSION=$_POST['updateVERSION'];
    $NOTES=$_POST['updateNOTES'];
    $currentID=$_POST['currentID'];

    $sql = "UPDATE info SET NAME='$NAME',
        MAC='$MAC',
        IP='$IP',
        LOCATION='$LOCATION',
        VIRUS='$VIRUS',
        VERSION='$VERSION',
        NOTES='$NOTES'
        WHERE ID=$currentID";
?>
ID is the primary key. When I echo out the vars and the sql I am getting the right information, however, my DB isn't updating. I can't figure it out because I have other include_once('filename') which work fine in the program and correctly display data, allow me to search, etc. I have tried many variations on altering the $currentID but it doesn't seem to make much difference. I am guessing it is a syntax problem, but after having worked on this page for god knows how many hours today, I am going nuts and can't see where my error is although it is likely very simple. Please help!

 
Old December 20th, 2004, 10:51 AM
Authorized User
 
Join Date: Dec 2004
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to peg110
Default

try adding:

    echo mysql_error().'<br>';


just after the mysql_query($sql); statemnt to see what it says. Very often an SQL error will not show in the PHP. You have to explicitly ask for it (using the mysql_error() )

Good Luck

Paul Gardner
------------------
PHP-LIVE help
Via Web @ http://www.mnetweb.co.uk/irc
Via IRC Client pgardner.net:6667
room #PHP
 
Old December 20th, 2004, 11:45 AM
Registered User
 
Join Date: Dec 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Geez, thank you. I'm sure you understand the enjoyment I'm experiencing right now as the error returned "No database selected.", somehow I must've deleted the include for the database!!!!!!!!!!!!! Ugh. Now i'm gonna go slap myself!

 
Old December 20th, 2004, 12:01 PM
Authorized User
 
Join Date: Dec 2004
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to peg110
Default

Been there done that. Got the T-Shirt.

Just glad I could help.

Paul Gardner
------------------
PHP-LIVE help
Via Web @ http://www.mnetweb.co.uk/irc
Via IRC Client pgardner.net:6667
room #PHP





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Updating MS Access database javlet Java Databases 1 April 24th, 2007 07:16 AM
updating database musicradiolive Classic ASP Databases 1 August 17th, 2006 12:23 AM
Problem getting updating Database from Datagrid RichardP ASP.NET 1.0 and 1.1 Basics 0 February 17th, 2006 07:55 AM
updating database problem nazra Classic ASP Databases 10 July 25th, 2003 08:27 PM





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