General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 11th, 2003, 01:58 AM
ignitionMX ignitionMX is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 13 ignitionMX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 3 sec
Reputation Power: 0
Send a message via ICQ to ignitionMX
Editting row problem

This is my first time posting a PLEASE HELP!!! topic here... so... I really appreciate it if someone could help me.

The Problem

When I tell my script to update the information in the database, it somehow cannot update.

So, I'm wondering if there's a solution to my script.

PHP Code:
case 'editBuild':
        if (
$row[permission] != 1
            {
                echo 
"<b>Error</b>";
                echo 
"<LI>You do not have the permission to view/edit the items on this page.<br>";
                echo 
"<b>Possible Solution(s)</b>";
                echo 
"<LI>Contact <a href=\"mailto:$admin_email\">$admin_name</a> to give you access rights.";
            }    
        else
            {        
                
$database mysql_connect("$dbHost","$dbUser","$dbPass");
                
mysql_select_db("$dbDatabase"$database);
                
                    
$id $_POST["id"];
                    
$user_name $_POST["username"];
                    
$email $_POST["email"];
                    
$birthday $_POST["birthday"];
                    
$biography $_POST["biography"];
                    
$permission $_POST["permission"];
                    
                    
$query  "UPDATE users ";
                    
$query .= "SET username = '$user_name', ";
                    
$query .= "    email = '$email', ";
                    
$query .= "    birthday = '$birthday', ";
                    
$query .= "    biography = '$biography', ";
                    
$query .= "    permission = '$permission', ";
                    
$query .= "WHERE id = $id";

                
$result mysql_query($query);
                if (
$result) { echo "The record has been editted."; }
                else { echo 
"Can't be done."; }
            }
    break; 


Thanks in advance!

Reply With Quote
  #2  
Old July 11th, 2003, 06:38 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Take a look at this line: if ($row[permission] != 1)
I think you should have quotes around permission.

Also, why so much space between your query items
PHP Code:
"    email = '$email', "
This doesn't need to have quotes
PHP Code:
 $database mysql_connect("$dbHost","$dbUser","$dbPass");
mysql_select_db("$dbDatabase"$database); 
single quotes would be faster
PHP Code:
 $id $_POST["id"]; 

These may not solve your problem, but it will help. Also, you might want to echo out your query and post it here.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old July 11th, 2003, 08:11 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
I think your problem might be the comma between the last set clause and the WHERE. Try pulling that out and see if it works.

Reply With Quote
  #4  
Old July 11th, 2003, 09:59 AM
_rainbow_ _rainbow_ is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Lj, Slovenia
Posts: 27 _rainbow_ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 28 sec
Reputation Power: 0
Try using error reporting side of PHP. If you put after all of your SQL statements (mysql_connect, mysql_select_db, mysql_query) a

PHP Code:
or die("An error has occured: ".mysql_error()." : ".mysql_errno()); 


it will help you a lot. Another thing that I find strange is the way you put together your query. Try it this way:

PHP Code:
 $query**=*"UPDATE users SET*username*= '$user_name',*email*= '$email',*birthday*= '$birthday',*biography*= '$biography', permission*= '$permission',*WHERE*id*=*$id"


I appologize for the wide post []

Reply With Quote
  #5  
Old July 11th, 2003, 10:56 AM
ignitionMX ignitionMX is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 13 ignitionMX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 3 sec
Reputation Power: 0
Send a message via ICQ to ignitionMX
Thanks dhouston! Yes, it was the comma.

To laidbak - I'll keep those single quotes in mind =D (I'm still a bit rusty on PHP.)

and to rainbow - I didn't like long strings or whatever you guys call it, so I made it the way I made it. Thanks for the error thing.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Editting row problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT