Gucci Mane Posted October 17, 2009 Posted October 17, 2009 I just added a new profile sig. mod I am having problems with the sql and the pref.php Sql (I need this fixed) ALTER users ADD `signature` text NOT NULL, preferences.php <?php /* MCCodes Lite preferences.php Rev 1.0.0 Copyright (C) 2006 Dabomstew This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ include "globals.php"; switch($_GET['action']) { case 'sexchange2': do_sex_change(); break; case 'sexchange': conf_sex_change(); break; case 'passchange2': do_pass_change(); break; case 'passchange': pass_change(); break; case 'namechange2': do_name_change(); break; case 'namechange': name_change(); break; case 'picchange2': do_pic_change(); break; case 'picchange': pic_change(); break; case 'signature2': do_signature_change(); break; case 'signature': signature_change(); break; default: prefs_home(); break; } function prefs_home() { global $ir,$c,$userid,$h; print "<h3>Preferences</h3> [url='preferences.php?action=sexchange']Sex Change[/url] [url='preferences.php?action=passchange']Password Change[/url] [url='preferences.php?action=namechange']Name Change[/url] [url='preferences.php?action=signature']Profile Signature[/url] [url='preferences.php?action=picchange']Display Pic Change[/url] "; } function conf_sex_change() { global $ir,$c,$userid,$h; if($ir['gender'] == "Male") { $g="Female"; } else { $g="Male"; } print "Are you sure you want to become a $g? [url='preferences.php?action=sexchange2']Yes[/url] | [url='preferences.php']No[/url]"; } function do_sex_change() { global $ir,$c,$userid,$h; if($ir['gender'] == "Male") { $g="Female"; } else { $g="Male"; } $db->query("UPDATE users SET gender='$g' WHERE userid=$userid",$c); print "Success, you are now $g! [url='preferences.php']Back[/url]"; } function pass_change() { global $ir,$c,$userid,$h; print "<h3>Password Change</h3><form action='preferences.php?action=passchange2' method='post'>Current Password: <input type='password' name='oldpw' /> New Password: <input type='password' name='newpw' /> Confirm: <input type='password' name='newpw2' /> <input type='submit' value='Change PW' /></form>"; } function do_pass_change() { global $ir,$c,$userid,$h; if($_POST['oldpw'] != $ir['userpass']) { print "The current password you entered was wrong. [url='preferences.php?action=passchange']> Back[/url]"; } else if($_POST['newpw'] !== $_POST['newpw2']) { print "The new passwords you entered did not match! [url='preferences.php?action=passchange']> Back[/url]"; } else { $db->query("UPDATE users SET userpass='{$_POST['newpw']}' WHERE userid=$userid",$c); print "Password changed!"; } } function name_change() { global $ir,$c,$userid,$h; print "<h3>Name Change</h3> Please note that you still use the same name to login, this procedure simply changes the name that is displayed. <form action='preferences.php?action=namechange2' method='post'> New Name: <input type='text' name='newname' /> <input type='submit' value='Change Name' /></form>"; } function do_name_change() { global $ir,$c,$userid,$h; if($_POST['newname'] == "") { print "You did not enter a new name. [url='preferences.php?action=namechange']> Back[/url]"; } else { $_POST['newname']=str_replace(array("<", ">", "\\\'"), array("<", ">", "'"), $_POST['newname']); $db->query("UPDATE users SET username='{$_POST['newname']}' WHERE userid=$userid",$c); print "Username changed!"; } } function signature_change() { global $ir,$c,$userid,$h; print "<h3>Profile Signature Change</h3> <form action='preferences.php?action=signature2' method='post'> New Profile Signature: <textarea rows=7 cols=40 name='newsignature'>{$ir['signature']}</textarea> <input type='submit' value='Change Profile Signature' /></form> [b]Current Profile Signature :[/b]{$r['signature']}"; } function do_signature_change() { global $ir,$c,$userid,$h; if($_POST['newsignature'] == "") { print "You did not enter a new signature. > [url='preferences.php?action=signature']Back[/url]"; } else { $db->query("UPDATE users SET signature='{$_POST['newsignature']}' WHERE userid=$userid",$c); print "Profile Signature changed!"; } } function pic_change() { global $ir,$c,$userid,$h; print "<h3>Pic Change</h3> Please note that this must be externally hosted, [url='http://imageshack.us']ImageShack[/url] is our recommendation. Any images that are not 150x150 will be automatically resized <form action='preferences.php?action=picchange2' method='post'> New Pic: <input type='text' name='newpic' value='{$ir['display_pic']}' /> <input type='submit' value='Change Name' /></form>"; } function do_pic_change() { global $ir,$c,$userid,$h; if($_POST['newpic'] == "") { print "You did not enter a new pic. [url='preferences.php?action=picchange']> Back[/url]"; } else { $_POST['newpic']=str_replace('\\\'',''', $_POST['newpic']); $db->query("UPDATE users SET display_pic='{$_POST['newpic']}' WHERE userid=$userid",$c); print "Pic changed!"; } } $h->endpage(); ?> I need the error in preferences fixed. The error is: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/jewelz/public_html/preferences.php on line 187 Quote
rulerofzu Posted October 17, 2009 Posted October 17, 2009 Does the middle ' in that line in your code appear as a ' or is it a htmlspecialcharacter ' Quote
a_bertrand Posted October 17, 2009 Posted October 17, 2009 Gucci Mane: actually what you are trying to do is done by a function called stripslashes() So replace line (187): $_POST['newpic']=str_replace('\\\'',''', $_POST['newpic']); With: $_POST['newpic']=stripslashes($_POST['newpic']); Quote
Joshua Posted October 17, 2009 Posted October 17, 2009 correct me if i'm wrong ALTER users ADD `signature` text NOT NULL, Would work if you did this ALTER users ADD `signature` text NOT NULL; Correct? or is it still the , just INSERT INTO users ADD `signature` text NOT NULL, shrugz, mysql with me is sketchy at best :P Quote
CrackTheCoder Posted October 17, 2009 Posted October 17, 2009 some help the person above has the right idea, but after ALTER u have to put TABLE so it would be... ALTER TABLE users ADD `signature` varchar(255) NOT NULL; i believe that is how u do it Quote
Joshua Posted October 18, 2009 Posted October 18, 2009 LOL forgot Table..haha..I'm not a noob I swear >< Above poster is correct > < Quote
Gucci Mane Posted October 18, 2009 Author Posted October 18, 2009 Thats works good thx guys...now i get this error when I try to add my sig Fatal error: Call to a member function query() on a non-object in /home/jewelz/public_html/preferences.php on line 164 Quote
Uridium Posted October 18, 2009 Posted October 18, 2009 Anywhere theres a global statement like this ====> global $ir,$c,$userid,$h; make it global $db, $ir,$c,$userid,$h; Quote
Gucci Mane Posted October 18, 2009 Author Posted October 18, 2009 can you tell me what to do to line 164?? Quote
Danny696 Posted October 18, 2009 Posted October 18, 2009 replace: global $ir,$c,$userid,$h; with: global $db,$ir,$c,$userid,$h; When did you start making your game Quote
Gucci Mane Posted October 18, 2009 Author Posted October 18, 2009 I still get this error : Fatal error: Call to a member function query() on a non-object in /home/jewelz/public_html/preferences.php on line 164 I did what you said Danny Quote
Danny696 Posted October 18, 2009 Posted October 18, 2009 replace $db->query("UPDATE users SET signature='{$_POST['newsignature']}' WHERE userid=$userid",$c); with mysql_query("UPDATE users SET signature='{$_POST['newsignature']}' WHERE userid=$userid",$c); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.