Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 09-15-2010, 12:48 PM   #1
96ukssob
So Fucking Banananananas
 
96ukssob's Avatar
 
Industry Role:
Join Date: Mar 2003
Location: If I was in your ass you'd know it
Posts: 12,991
any PHP guys around? have a question

I'm trying to mess around with script to edit a single row in a table, but for some reason, it wont update.

Anyone help out? p-p-p-please

edit page
PHP Code:
<?php
mysql_connect
("localhost","username","password") or die("Error: ".mysqlerror());
mysql_select_db("db_name");
$sql "select * from `ring` where ID = 'user'";
$query mysql_query($sql);
while (
$row mysql_fetch_array($query)){
    
$id $row['ID'];
    
$value $row['value'];
    
$text $row['text'];
    
$image $row['image'];
}
mysql_free_result($query);
?>
<html>
<head>
<title>Edit User Info</title>
</head>
<body>
<form action="updateinfo.php" method="post">
ID:<br/>
<input type="text" value="<?php echo $id;?>" name="id" disabled/>
<br/>
Value:<br/>
<input type="text" value="<?php echo $value;?>" name="value"/>
<br/>
Text:<br/>
<input type="text" value="<?php echo $text;?>" name="text"/>
<br/>
Image:<br/>
<input type="text" value="<?php echo $image;?>" name="image"/>
</br>
<input type="submit" value="submit changes"/>
</form>
</body>
</html>
and here is the update info page

PHP Code:
<?php
mysql_connect
("localhost","username","password") or die("Error: ".mysqlerror());
mysql_select_db("db_name");
$id $row['ID'];
$value $row['value'];
$text $row['text'];
$image $row['image'];
$sql "UPDATE `ring` SET `value` = '$value',`text` = '$text',`image` = '$image' WHERE `ring`.`ID` = '$id' LIMIT 1";
mysql_query($sql) or die ("Error: ".mysql_error());
echo 
"Database updated. <a href='editinfo.php'>Return to edit info</a>";
?>
the single user that I am trying to edit is named "user" in the table

i'll have some paypal sent later this week if someone wants a few bucks, or let me know how i can help you out
__________________
Email: Clicky on Me
96ukssob is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-15-2010, 12:56 PM   #2
woj
<&(©¿©)&>
 
woj's Avatar
 
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
in that 2nd file, you need use $_POST instead of $row, but still I hope you are just playing around and aren't actually planning to use this on a live site, that code is full of holes...
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

Last edited by woj; 09-15-2010 at 12:59 PM..
woj is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-15-2010, 01:10 PM   #3
96ukssob
So Fucking Banananananas
 
96ukssob's Avatar
 
Industry Role:
Join Date: Mar 2003
Location: If I was in your ass you'd know it
Posts: 12,991
Quote:
Originally Posted by woj View Post
in that 2nd file, you need use $_POST instead of $row, but still I hope you are just playing around and aren't actually planning to use this on a live site, that code is full of holes...
its just something I am messing around with, but no wont be anything public.

i changed the $row to $_POST and still not storing in the DB. I changed the file permissions to 777 from 644... any other suggestions

PHP Code:
<?php
mysql_connect
("localhost","username","password") or die("Error: ".mysqlerror());
mysql_select_db("db_name");
$id $_POST['ID'];
$value $_POST['value'];
$text $_POST['text'];
$image $_POST['image'];
$sql "UPDATE `ring` SET `value` = '$value',`text` = '$text',`image` = '$image' WHERE `ring`.`ID` = '$id' LIMIT 1";
mysql_query($sql) or die ("Error: ".mysql_error());
echo 
"Database updated. <a href='editinfo.php'>Return to edit info</a>";
?>
__________________
Email: Clicky on Me
96ukssob is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-15-2010, 01:14 PM   #4
EDepth
Confirmed User
 
Join Date: Nov 2005
Location: Seattle, WA
Posts: 510
id is lowercase in the form, uppercase in your code?
__________________
ICQ: 275335837
EDepth is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-15-2010, 01:20 PM   #5
grumpy
Too lazy to set a custom title
 
grumpy's Avatar
 
Join Date: Jan 2002
Location: Holland
Posts: 9,870
add
echo $sql;

and see if the line is correct or post it here
__________________
Don't let greediness blur your vision | You gotta let some shit slide
icq - 441-456-888
grumpy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-15-2010, 01:21 PM   #6
Jakez
Confirmed User
 
Jakez's Avatar
 
Industry Role:
Join Date: Jan 2004
Location: oddfuturewolfgangkillthemall!!!!!!!
Posts: 5,656
When something isn't working and I can't for the life of me figure out why I usually just start "dieing" stuff out, try:
die($sql)

Then you can see exactly what it's telling mysql and copy/paste it into phpmyadmins SQL query box. Haven't used mysql_error() in a while but phpmyadmin will give you some good info about the query if it fails or not.
__________________
[email protected] - jakezdumb - 573689400

Killuminati
Jakez is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-15-2010, 01:22 PM   #7
96ukssob
So Fucking Banananananas
 
96ukssob's Avatar
 
Industry Role:
Join Date: Mar 2003
Location: If I was in your ass you'd know it
Posts: 12,991
Quote:
Originally Posted by EDepth View Post
id is lowercase in the form, uppercase in your code?
i changed it from ID to id... still wont update in the db
__________________
Email: Clicky on Me
96ukssob is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-15-2010, 01:25 PM   #8
davethedope
Confirmed User
 
Join Date: Dec 2005
Posts: 532
it's probably not connecting to "localhost" use the server name.
davethedope is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-15-2010, 01:25 PM   #9
96ukssob
So Fucking Banananananas
 
96ukssob's Avatar
 
Industry Role:
Join Date: Mar 2003
Location: If I was in your ass you'd know it
Posts: 12,991
Quote:
Originally Posted by grumpy View Post
add
echo $sql;

and see if the line is correct or post it here
Quote:
Originally Posted by Jakez View Post
When something isn't working and I can't for the life of me figure out why I usually just start "dieing" stuff out, try:
die($sql)

Then you can see exactly what it's telling mysql and copy/paste it into phpmyadmins SQL query box. Haven't used mysql_error() in a while but phpmyadmin will give you some good info about the query if it fails or not.
thanks guys

here is the output...
Code:
UPDATE `ring` SET `value` = '75',`text` = 'blah blah',`image` = 'image' WHERE `ring`.`id` = '' LIMIT 1
__________________
Email: Clicky on Me
96ukssob is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-15-2010, 01:25 PM   #10
EDepth
Confirmed User
 
Join Date: Nov 2005
Location: Seattle, WA
Posts: 510
is ID uppercase in your db table as well or lower?
__________________
ICQ: 275335837
EDepth is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-15-2010, 01:26 PM   #11
EDepth
Confirmed User
 
Join Date: Nov 2005
Location: Seattle, WA
Posts: 510
eh nevermind, looks like your not setting the $id variable for some reason. Most likely lowercase/uppercase in your $_POST or form vars.
__________________
ICQ: 275335837
EDepth is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-15-2010, 01:27 PM   #12
96ukssob
So Fucking Banananananas
 
96ukssob's Avatar
 
Industry Role:
Join Date: Mar 2003
Location: If I was in your ass you'd know it
Posts: 12,991
AHHH! figured it out! i'm a knuckle head

had to change

PHP Code:
$sql "UPDATE `ring` SET `value` = '$value',`text` = '$text',`image` = '$image' WHERE `ring`.`id` = '$id' LIMIT 1"
to

PHP Code:
$sql "UPDATE `ring` SET `value` = '$value',`text` = '$text',`image` = '$image' WHERE `ring`.`id` = 'user' LIMIT 1"


thanks for the help
__________________
Email: Clicky on Me
96ukssob is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-15-2010, 01:30 PM   #13
grumpy
Too lazy to set a custom title
 
grumpy's Avatar
 
Join Date: Jan 2002
Location: Holland
Posts: 9,870
a little echo can save the day
__________________
Don't let greediness blur your vision | You gotta let some shit slide
icq - 441-456-888
grumpy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.