Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP MySQL Update Problem
Old 06-27-2005, 08:51 PM PHP MySQL Update Problem
Junior Talker

Posts: 2
Trades: 0
OK, I literally jumped into PHP tonight. Ive been going for about 6 hours now. All i did before this was include scripts. Im making a admin page for my site to quickly update my members. I have everything working fine. Adding people, viewing them, etc. The edit and update page are killing me though. Heres the script for my edit page:

PHP Code:
<?
$id 
$_GET['id']; 

$username="afh_um";
$password="*****";

$db mysql_connect("localhost"$username,$password );
mysql_select_db("afh_umblah",$db);
$result mysql_query("SELECT * FROM members WHERE id='$id'",$db);

$num=mysql_numrows($result);

mysql_close();


$name=mysql_result($result,$i,"name");
$rank=mysql_result($result,$i,"rank");
$char=mysql_result($result,$i,"char");
$aka=mysql_result($result,$i,"aka");
$recby=mysql_result($result,$i,"recby");

echo 
"<b><center>Editing $name</b><br><br>";

echo 
"<form action=update.php method=post><input type=hidden name=ud_id value=$id><br>Name: <br><textarea name=ud_name>$name</textarea><br>Rank: <br> <input type=text maxlength=50 value=$rank name=ud_rank><br>Char: <br><input type=text maxlength=50 value=$char name=ud_char><br>AKA's: <br><input type=text maxlength=200 value=$aka name=ud_aka><br>Recruited By: <br><input type=text maxlength=50 value=$recby name=ud_recby><br><br><input type=submit value=Update></center>";

?>
works fine. the website adress is something like edit.php?id=### and then it retrieves and uses that to pull the other info. Another problem I had here was that I wanted to display the info in text inputs and it would only display the first word. Thats why you see the textarea. Any help with that also would be generous. So I'm guessing thats working fine, so then when your done editing, it submits to this, my update.php page:

PHP Code:
<?

$ud_id
=$_POST['ud_id'];
$ud_name=$_POST['ud_name'];
$ud_rank=$_POST['ud_rank'];
$ud_char=$_POST['ud_char'];
$ud_aka=$_POST['ud_aka'];
$ud_recby=$_POST['ud_recby'];

$username="afh_um";
$password="*****";

$db mysql_connect("localhost"$username,$password );
mysql_select_db("afh_umblah",$db);


$query="UPDATE members SET name='$ud_name', rank='$ud_rank', char='$ud_char', aka='$ud_aka', recby='$ud_recby' WHERE id='$ud_id'";
mysql_query($query);
echo 
"Record Updated";
mysql_close();

?>
It says Record Updated, I go back to view the changed info, still the same. Refresh about 50 times out of anger, still the same. Any help will be appreciated. Thanks.

-Shiv
Shiv is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-28-2005, 12:56 AM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
$query="UPDATE members SET name='$ud_name', rank='$ud_rank', char='$ud_char', aka='$ud_aka', recby='$ud_recby' WHERE id='$ud_id'";

while($row = mysql_fetch_array($query)){
echo " Record entered successfull";
}
else
{
echo " Error , can't be entered";
}
?>
__________________
Life is just lyke a school where everybody goes to learn one or two thing. the more u school, the more u learn more about school..The more we live our lifes.. the more we learn more about life.

Please login or register to view this content. Registration is FREE
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Reply     « Reply to PHP MySQL Update Problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10279 seconds with 12 queries