Jump to content

stripslashes


ecabrera

Recommended Posts

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);


?>

Link to comment
https://forums.phpfreaks.com/topic/251407-stripslashes/
Share on other sites

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);

 

 

?>

Link to comment
https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289445
Share on other sites

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 \

Link to comment
https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289483
Share on other sites

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";
?>

 

Link to comment
https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289489
Share on other sites

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);


?>

Link to comment
https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289609
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/251407-stripslashes/#findComment-1289618
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.