View Single Post
Old 08-23-2007, 06:31 PM  
testpie
Mostly retired
 
testpie's Avatar
 
Industry Role:
Join Date: Apr 2006
Location: UK
Posts: 3,231
Quote:
Originally Posted by dirtysouth View Post
Got a page where users can edit their account details ie: useredit.php

That page posts to "do-useredit.php

User must be logged in. Here's some code:

useredit.php

PHP Code:
<?php
require_once('../mysql_connect.php');
session_start();

if(isset(
$_SESSION['id']))
{
    
$mn trim($_SESSION['id']);
    require_once(
'../mysql_connect.php');
    
$query "SELECT * FROM shoppingmembers WHERE member_name = '$mn'";
    
$result mysql_query($query);
    
$row mysql_fetch_array($resultMYSQL_ASSOC);
}

echo
'


<form name="form1" method="post" action="do-useredit.php">
<input type="text" name="bill_fname" value="' 
$row['bill_fname'] . '" style="font-size:9px"><br />
<input type="submit" name="submit" value="Update" />'
;

?>
Here's the second page:

do-useredit.php

PHP Code:
<?php
require_once('../mysql_connect.php');
session_start();



$_GET['mn'];


if(isset(
$_SESSION['id']))
{
    
$mn trim($_SESSION['id']);
    require_once(
'../mysql_connect.php');
    
$query "SELECT * FROM shoppingmembers WHERE member_name = '$mn'";
    
$result mysql_query($query);
    
$row mysql_fetch_array($resultMYSQL_ASSOC);



}



mysql_query("UPDATE shoppingmembers SET bill_fname = '$bill_fname' WHERE member_name = 'admin'")or die(mysql_error());



echo 
"Record Updated";
print 
$mn;



?>
Problem: When I have session_start in the top of do-useredit.php, it doesn't UPDATE. When I comment it out it works fine. The trouble is, I can't pass the member_name into the query, hence in the above I simply force it to UPDATE WHERE member_name = 'admin' (me). Any ideas? I have paypal funds avail. TIA!
You're running this segment of code:
PHP Code:
if(isset($_SESSION['id']))
{
    
$mn trim($_SESSION['id']);
    require_once(
'../mysql_connect.php');
    
$query "SELECT * FROM shoppingmembers WHERE member_name = '$mn'";
    
$result mysql_query($query);
    
$row mysql_fetch_array($resultMYSQL_ASSOC);




before the update SQL below, so I'd guess your problem has something to do with trying to dray the session ID out and put it into the SQL query. Try changing:
PHP Code:
$result mysql_query($query); 
to:
PHP Code:
$result mysql_query($query) or die("Error: ".mysql_error()); 
and see if that gives you an SQL error.
__________________

Affiliates: DogFart ~ Domain parking: NameDrive ~ Traffic broker: Traffic Holder
testpie is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote