ecabrera Posted November 19, 2011 Share Posted November 19, 2011 when i update something it doesnt show when i click on the page i updated in and i add stripslashes to remove the \ if i remove the stripslashes i get the \ and i dont like that <?php if(isset($_POST['update'])){ require "scripts/connect.php"; // Set some values to go into the table fields for this person(record) $intro = stripslashes($_POST ['intro']); $latestnews = stripslashes($_POST ['latestnews']); $maincontent = stripslashes($_POST ['maincontent']); $mainvideos = stripslashes($_POST ['mainvideos']); echo "Good Job $username you have UPDATED SUCCESSFULLY!!"; } // Build the sql command string $sqlCommand = "UPDATE content SET intro='$intro', latestnews='$latestnews', maincontent='$maincontent', mainvideos='$mainvideos'"; // Execute the query here now $query = mysql_query($sqlCommand); ?> Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/ Share on other sites More sharing options...
Pikachu2000 Posted November 19, 2011 Share Posted November 19, 2011 As I said in your other thread that's the same problem as this one, you most likely have magic_quotes_gpc set to ON in your php.ini file. It should be OFF. Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289438 Share on other sites More sharing options...
ecabrera Posted November 19, 2011 Author Share Posted November 19, 2011 if i trun it off it wont work Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289439 Share on other sites More sharing options...
Pikachu2000 Posted November 19, 2011 Share Posted November 19, 2011 Define "won't work". Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289441 Share on other sites More sharing options...
ecabrera Posted November 19, 2011 Author Share Posted November 19, 2011 when its off and i try to update my site with out the stripslashes it wont let me update Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289443 Share on other sites More sharing options...
Pikachu2000 Posted November 19, 2011 Share Posted November 19, 2011 You need to use mysql_real_escape_string() for data that will be used in a query string. Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289444 Share on other sites More sharing options...
ecabrera Posted November 19, 2011 Author Share Posted November 19, 2011 so it should look like this <?php if(isset($_POST['update'])){ require "scripts/connect.php"; // Set some values to go into the table fields for this person(record) $intro = mysql_real_escape_string($_POST ['intro']); $latestnews =mysql_real_escape_string($_POST ['latestnews']); $maincontent = mysql_real_escape_string($_POST ['maincontent']); $mainvideos = mysql_real_escape_string($_POST ['mainvideos']); echo "Good Job $username you have UPDATED SUCCESSFULLY!!"; } // Build the sql command string $sqlCommand = "UPDATE content SET intro='$intro', latestnews='$latestnews', maincontent='$maincontent', mainvideos='$mainvideos'"; // Execute the query here now $query = mysql_query($sqlCommand); ?> Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289445 Share on other sites More sharing options...
ecabrera Posted November 19, 2011 Author Share Posted November 19, 2011 ok so i have it like this <?php require "scripts/connect.php"; $sqlCommand = ("SELECT * FROM content"); $query = mysql_query($sqlCommand); while ($row = mysql_fetch_array($query)) { // Gather all $row values into local variables for easier usage in output $intro = stripslashes($row ['intro']); $latestnews = stripslashes($row ['latestnews']); $maincontent= stripslashes($row ['maincontent']); $mainvideos = stripslashes($row ['mainvideos']); } ?> but i still get \ Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289483 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 19, 2011 Share Posted November 19, 2011 you are not echoing anything. how can you get the "\" ? Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289484 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 19, 2011 Share Posted November 19, 2011 and, did you restart your web server? Every single time you update your php.ini or httpd.conf, you MUST restart restart your web server to make the changes available. Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289485 Share on other sites More sharing options...
ecabrera Posted November 19, 2011 Author Share Posted November 19, 2011 ok now it doesnt show any \ but when i click updated i doesnt want to update any of my stuff i put in Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289486 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 19, 2011 Share Posted November 19, 2011 what you mean update? from the code you gave us, its just showing the values in the db. not updating the db. please be more specific. Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289488 Share on other sites More sharing options...
ecabrera Posted November 19, 2011 Author Share Posted November 19, 2011 this when i update my page <?php session_start(); $username = $_SESSION['username']; ?> <?php require "scripts/connect.php"; $sqlCommand = ("SELECT * FROM content"); $query = mysql_query($sqlCommand); while ($row = mysql_fetch_array($query)) { // Gather all $row values into local variables for easier usage in output $intro = stripslashes($row ['intro']); $latestnews = stripslashes($row ['latestnews']); $maincontent= stripslashes($row ['maincontent']); $mainvideos = stripslashes($row ['mainvideos']); } ?> <?php require "header.php"; ?> <?php if ($username){?> <?php echo "<br/><br/>"."Welcome <b>$username</b>, <a href='logout.php'>Logout</a href>"."<br /><br />"; ?> <?php if(isset($_POST['update'])){ require "scripts/connect.php"; // Set some values to go into the table fields for this person(record) $intro = $_POST ['intro']; $latestnews = $_POST ['latestnews']; $maincontent = $_POST ['maincontent']; $mainvideos = $_POST ['mainvideos']; echo "Good Job $username you have UPDATED SUCCESSFULLY!!"; } // Build the sql command string $sqlCommand = "UPDATE content SET intro='$intro', latestnews='$latestnews', maincontent='$maincontent', mainvideos='$mainvideos'"; // Execute the query here now $query = mysql_query($sqlCommand); ?> <?php echo "<center><h2>Hey $username! What do you want to do?</h2></center>"; ?> <div id="ahome"> <form action='adminpanel.php' method='POST'> <table> <tr> <td>Intro</td> <td><textarea name='intro' cols=50 rows=15><?php echo $intro; ?></textarea></td> </tr> <tr> <td>Latest News</td> <td><textarea name='latestnews' cols=50 rows=15><?php echo $latestnews; ?></textarea></td> </tr> <tr> <td>Main Content</td> <td><textarea name='maincontent' cols=50 rows=15><?php echo $maincontent; ?></textarea></td> </tr> <tr> <td>Main Videos</td> <td><textarea name='mainvideos' cols=50 rows=15><?php echo $mainvideos; ?></textarea></td> </tr> <tr> <td></td> <td><input type='submit' name='update' value='Update'></td> </tr> </table> </form> </div> <?php } else echo "<font color='red'><center><h1>You must be logged in to view this page.</h1></center></font>"; ?> <?php require "footer.php"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289489 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 19, 2011 Share Posted November 19, 2011 the function require must be in brackets eg. <?php require("scripts/connect.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289493 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 19, 2011 Share Posted November 19, 2011 have you learnt php basics? i assuming you dont understand the function of while loop, variables and sessions. Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289495 Share on other sites More sharing options...
ecabrera Posted November 19, 2011 Author Share Posted November 19, 2011 no Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289496 Share on other sites More sharing options...
Pikachu2000 Posted November 19, 2011 Share Posted November 19, 2011 the function require must be in brackets eg. <?php require("scripts/connect.php"); ?> require is a language construct, not a function, and it does not need to be used with parentheses. Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289522 Share on other sites More sharing options...
ecabrera Posted November 19, 2011 Author Share Posted November 19, 2011 ok so i dont see any \ now but when i try to update me profile page it doesnt update <?php require("scripts/connect.php"); $sqlCommand = ("SELECT * FROM content"); $query = mysql_query($sqlCommand); while ($row = mysql_fetch_array($query)) { // Gather all $row values into local variables for easier usage in output $intro = stripslashes($row ['intro']); $latestnews = stripslashes($row ['latestnews']); $maincontent= stripslashes($row ['maincontent']); $mainvideos = stripslashes($row ['mainvideos']); } ?> <?php require "header.php"; ?> <?php if ($username){?> <?php echo "<br/><br/>"."Welcome <b>$username</b>, <a href='logout.php'>Logout</a href>"."<br /><br />"; ?> <?php if(isset($_POST['update'])){ require ("scripts/connect.php"); // Set some values to go into the table fields for this person(record) $intro = $_POST ['intro']; $latestnews = $_POST ['latestnews']; $maincontent = $_POST ['maincontent']; $mainvideos = $_POST ['mainvideos']; echo "Good Job $username you have UPDATED SUCCESSFULLY!!"; } // Build the sql command string $sqlCommand = "UPDATE content SET intro='$intro', latestnews='$latestnews', maincontent='$maincontent', mainvideos='$mainvideos'"; // Execute the query here now $query = mysql_query($sqlCommand); ?> Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289609 Share on other sites More sharing options...
Pikachu2000 Posted November 19, 2011 Share Posted November 19, 2011 What does mysql_error() tell you about why it won't update? Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289611 Share on other sites More sharing options...
ecabrera Posted November 19, 2011 Author Share Posted November 19, 2011 it doesn not give me errors Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289614 Share on other sites More sharing options...
Pikachu2000 Posted November 19, 2011 Share Posted November 19, 2011 In your php.ini file, you should have the following directives set as follows. Find them in the php.ini file and if they are not set like that, make those changes, save the file, restart Apache and post whatever errors are generated when you run the script. error_reporting = -1 display_errors = On Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289618 Share on other sites More sharing options...
ecabrera Posted November 19, 2011 Author Share Posted November 19, 2011 no errors Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289619 Share on other sites More sharing options...
ZulfadlyAshBurn Posted November 20, 2011 Share Posted November 20, 2011 at the top of your code add this <?php // error reporting error_reporting(E_ALL); ini_set('display_errors', '1'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289703 Share on other sites More sharing options...
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.