View Single Post
Old 03-29-2008, 04:02 PM   #1 (permalink)
subman
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