Jump to content


This topic is now archived and is closed to further replies.


Problem with Function

Recommended Posts

Hi all,

I have the following script for a user to update their details:

$id = $_SESSION['username'];
$query = "select * from suppliers where username='$id'";

    //now we pass the query to the database 
    $result=mysql_query($query, $link) or die("MySQL query $query failed.  Error if any: ".mysql_error());

    //get the first (and only) row from the result 
    $row = mysql_fetch_array($result, MYSQL_ASSOC); 

if(empty($messages)) {
    updateuser ($username=$row['username'], 


I then have html below that:

<form name="form1" method="post" action="<?=$_SERVER["PHP_SELF"]?>" onSubmit="return check()"> 
    <?php echo $username; ?> 
  <p>First Name: 
    <input type="text" name="first_name" value="<?php echo $first_name; ?>"> 
  <p>Last Name: 
    <input type="text" name="last_name" size="10" value="<?php echo $last_name; ?>"> 
  <p>Address Line 1: 
    <input type="text" name="address_line1" size="10" value="<?php echo $address_line1; ?>"> 
  <p>Address Line 2: 
    <input type="text" name="address_line2" size="10" value="<?php echo $address_line2; ?>"> 
    <input type="text" name="town" size="10" value="<?php echo $town; ?>"> 
etc, etc 

The problem is that the html is not being populated with the data and is not posting either, I have simply copied the function from a newuser function when a user signs up, the function as it is in the functions file looks like so:

function updateuser ($password, $username, $first_name, $last_name, $address_line1, $address_line2, $town, $county, $postcode, $daytime_phone, $mobile_phone, $email_address) {

global $link;

$query="UPDATE suppliers SET password='$password', username='$username', first_name='$first_name', last_name='$last_name',  address_line1='$address_line1', address_line2='$address_line2', town='$town' , county='$county', postcode='$postcode', daytime_phone='$daytime_phone', mobile_phone='$mobile_phone', email_address='$email_address' where username= '$username'";

$result=mysql_query($query, $link) or die("Died inserting login info into db.  Error returned if any: ".mysql_error());

return true;
} // 

Any help would be much appreciated as I am really stuck.



Share this post

Link to post
Share on other sites
Not sure if this is what you mean, but I just added:

//Check if $message is set, and output it if it is:

Still no joy though

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.