...

View Full Version : Not getting the values



elvn0
03-09-2008, 03:33 AM
<?php
function sql_quote($data) {
if (get_magic_quotes_gpc()) {
$data = stripslashes($data);
}

return addslashes($data);
}
$id = sql_quote($_GET['id']);
$action = sql_quote($_GET['action']);
include 'config.php';
include 'opendb.php';
$id = mysql_real_escape_string($id); // helps protect against injections

$query = "SELECT * FROM `members` WHERE `id` = '{$id}' ";

$result = mysql_query($query) or die(mysql_error());

$name=$row['name'];
$rank=$row['rank'];
$lastname=$row['lastname'];
$pos=$row['pos'];
$s=$row['squad'];
$asn=$row['asn'];
$tour=$row['tour'];
?>

<form name="update" action="edit_profile.php?action=edit method="post">
Name:<input type="text" name="name" value="<?php print $name; ?>"/>
Last name:<input type="text" name="lastname" value="<?php print $lastname; ?>"/>
Rank:<input type="text" name="rank" value="<?php print $rank; ?>"/>
Pos:<input type="text" name="pos" value="<?php print $pos; ?>"/>

<input type="submit" name="submit" value="save"/>
</form>

It's not getting the values from database and put them into text fields.

What am i doing wrong?

Mwnciau
03-09-2008, 04:30 AM
You're missing:


$row = mysql_fetch_array ( $result ); // or mysql_fetch_assoc

elvn0
03-09-2008, 05:41 AM
<?php
function sql_quote($data) {
if (get_magic_quotes_gpc()) {
$data = stripslashes($data);
}

return addslashes($data);
}
$id = sql_quote($_GET['id']);
$action = sql_quote($_GET['action']);
include 'config.php';
include 'opendb.php';
$id = mysql_real_escape_string($id); // helps protect against injections

$query = "SELECT * FROM `members` WHERE `id` = '{$id}' ";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);

$name=$row['name'];
$rank=$row['rank'];
$lastname=$row['lastname'];
$pos=$row['pos'];
$s=$row['squad'];
$asn=$row['asn'];
$tour=$row['tour'];
?>

<form name="update" action="edit_profile.php?action=edit" method="post">
Name:<input type="text" name="name" value="<?php print $name; ?>"/>
Last name:<input type="text" name="lastname" value="<?php print $lastname; ?>"/>
Rank:<input type="text" name="rank" value="<?php print $rank; ?>"/>
Pos:<input type="text" name="pos" value="<?php print $pos; ?>"/>

<input type="submit" name="submit" value="save"/>
</form>



Still not working and not giving me an error either.

rafiki
03-09-2008, 11:23 AM
or die(mysql_error());

abduraooft
03-09-2008, 03:34 PM
Just echo your $query and copy the generated string. Try to execute it in mysql console or phpmyadmin interface, and check the result.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum