TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-29-2008, 04:02 PM   #1 (permalink)
The Wanderer
 
Join Date: Mar 2008
Posts: 7
Thanks: 2
subman is on a distinguished road
Default Missing argument

Hello

Im having a problem updating my mysql database through php...

The Errors
PHP Code:
WarningMissing argument 1 for userUpdate(), called in C:\wamp\www\php\users\admin.php on line 32 and defined in C:\wamp\www\php\users\adminfunctions.php on line 37

Warning
Missing argument 2 for userUpdate(), called in C:\wamp\www\php\users\admin.php on line 32 and defined in C:\wamp\www\php\users\adminfunctions.php on line 37

Warning
Missing argument 3 for userUpdate(), called in C:\wamp\www\php\users\admin.php on line 32 and defined in C:\wamp\www\php\users\adminfunctions.php on line 37

Warning
Missing argument 4 for userUpdate(), called in C:\wamp\www\php\users\admin.php on line 32 and defined in C:\wamp\www\php\users\adminfunctions.php on line 37
You have an error in your SQL syntax
check the manual that corresponds to your MySQL server version for the right syntax to use near 'email accesslevel FROM users WHERE username = '' AND password = '' AND email = '' at line 1 

And the adminfunctions.php file

PHP Code:
<?php
//Admin Functions
include("config.php");


/**
 * Displays the user and allows you to edit them
 */
function editUser($user) {
    if(isset(
$_POST['edituser'])){
    
$sql "SELECT * FROM `users` WHERE `username` = '$user'";
    
$query mysql_query($sql) or die(mysql_error());
while (
$fetch mysql_fetch_array($query))
{
    
$form  '<form name="Edit" method="POST" action="admin.php?action=update">';
    
$form .= '<h3><b>Editing User '.$fetch['username']. '-</b></h3><br />';
    
$form .= 'Username: <input type="text" name="user" value="'.$fetch['username'].'"/><br />';
    
$form .= 'Password: <input type="password" name="pass" value="'.$fetch['password'].'"/><br />';
    
$form .= 'Email: <input type="text" name="email" value="'.$fetch['email'].'"/><br />';
    
$form .= 'Access Level: <input type="text" name="email" value="'.$fetch['accesslevel'].'"/><br />';
    
$form .= '<input type="submit" name="updateuser" value="Submit"/>';
    
$form .= '</form>';
    echo 
$form;    

}
}

function 
selectUser() {
    
$form  '<form name="Edit" method="POST" action="admin.php?action=edit">';
    
$form .= '<h3><b>Select User -</b></h3><br />';
    
$form .= 'Username: <input type="text" name="user" value=""/><br />';
    
$form .= '<input type="submit" name="edituser" value="Submit"/>';
    
$form .= '</form>';
    echo 
$form;
}

function 
userUpdate($user$pass$email$access) {
    if(isset(
$_POST['updateuser'])){
    
$sql "UPDATE username password email accesslevel FROM users WHERE username = '$user' AND password = '$pass' AND email = '$email' AND accesslevel = '$access' LIMIT 1;";
    
$query mysql_query($sql) or die(mysql_error());
}
}

function 
deleteUser() {
    
}

function 
siteConfig() {
    
}

function 
updateConfig() {
    
}

function 
viewUsers() {
    
$sql "SELECT * FROM `users` ORDER BY user_id";
echo 
'Users Currently Registered:<br />';
$query mysql_query($sql) or die(mysql_error());
while (
$fetch mysql_fetch_array($query))
{
        
        echo 
"- "
        echo 
$fetch['username'] . "<br />\n";

}
?>


Also admin.php

PHP Code:
<?php
session_start
();
include(
"config.php");
include(
"adminfunctions.php");
if (!isset(
$_SESSION['user']) OR($_SESSION['access_level'] != 10)) {
    
header('Location: menu.php');
    exit();
}
echo 
'Hello '.$_SESSION['user']. '!, Welcome to the admin panel!<br />';
echo 
'Menu: <br />';
echo 
'<a href="admin.php?action=config">Update Site Configurtaion</a><br />';
echo 
'<a href="admin.php?action=select">Edit User</a><br />';
echo 
'<a href="admin.php?action=delete">Delete User</a><br />';
echo 
'<a href="admin.php?action=members">View Users</a><br />';


switch (
$_GET['action']) {
    case 
'select':
        echo 
'<center>Select User To Edit';
        
        
selectUser();
        echo 
"</center>";
        break;
    case 
'edit':
        echo 
"<center>";
        
editUser($_POST['user']);
        echo 
"</center>";
        
        break;
    case 
'update':
        echo 
'<center>User Updated</center>';
        
userUpdate();
        
        break;
    case 
'delete':
        echo 
'<center>Delete User</center>';
        
deleteUser();
        
        break;
    case 
'config':
        echo 
'<center>Site Configuration</center>';
        
siteConfig();
        
        
        break;
    case 
'members':
        echo 
"<center>";
        
viewUsers();
        echo 
"</center>";
            break;
}

?>

Any thoughts?
subman is offline  
Reply With Quote
Old 03-29-2008, 04:04 PM   #2 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default

You call:
userUpdate();

But the funcion userUpdate needs 4 parameters....
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
The Following User Says Thank You to freenity For This Useful Post:
subman (03-29-2008)
Old 03-29-2008, 04:06 PM   #3 (permalink)
The Wanderer
 
Join Date: Mar 2008
Posts: 7
Thanks: 2
subman is on a distinguished road
Default

Haha i feel dumb now... Thanks alot!
subman is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:58 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design