Having problems storing 's from my php form to the database.

Having problems storing 's from my php form to the database.

here is the line that stores the review text. ContentText = ‘$_POST[review_text]’,

I tried this I ment I tried like this ContentText = ‘".mysql_real_escape_string ($_POST[review_text])."’

but I don’t see any text stored in the text box.

What am I doing wrong?

[php]<?
require_once("…/conn.php");
require_once("…/includes.php");
require_once(“access.php”);
require_once(“AdminNavigation.php”);
if(isset($_POST[s1]))
{
$q1 = "update games_content set
ItemID = ‘$_POST[item_id_1]’,
ContentTitle = ‘$_POST[review_title]’,
ContentText = ‘$_POST[review_text]’,
rating = ‘$_POST[rating]’

                            where ContentID = '$_GET[ContentID]' ";

mysql_query($q1);
if(!mysql_error())
{
$message1 = “
This review has been updated!”;
$message2 = “<a href=“list_content.php?cmd=review&ItemID=$_GET[ItemID]” class=BlackLink>Back to reviews”;
}
}
//get the review info
$q1 = "select * from games_content where ContentID = ‘$_GET[ContentID]’ ";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
?>


Edit this review<?=$message1?>
Game: <?=select_item($a1[ItemID], "item_id_1");?>
Review Title:
Add Gossip here: <?=$a1[ContentText]?>
Rate game: <?=select_rating($a1[rating]);?>
<?=$message2?>
<? require_once("admin_footer.php"); ?>[/php]

try this:

[php]<?
require_once("…/conn.php");
require_once("…/includes.php");
require_once(“access.php”);
require_once(“AdminNavigation.php”);
if(isset($_POST[s1]))
{
$q1 = “update games_content set
ItemID = '”.$_POST[‘item_id_1’]."’,
ContentTitle = ‘".$_POST[‘review_title’]."’,
ContentText = ‘".$_POST[‘review_text’]."’,
rating = ‘".$_POST[‘rating’]."’
where ContentID = ‘".$_GET[‘ContentID’]."’ “;
mysql_query($q1);
if(!mysql_error())
{
$message1 = “
This review has been updated!”;
$message2 = “<a href=“list_content.php?cmd=review&ItemID=”.$_GET[‘ItemID’].”” class=BlackLink>Back to reviews";
}
}
//get the review info
$q1 = “select * from games_content where ContentID = '”.$_GET[‘ContentID’]."’ ";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
?>


Edit this review<?=$message1?>
Game: <?=select_item($a1[ItemID], "item_id_1");?>
Review Title:
Add Gossip here: <?=$a1[ContentText]?>
Rate game: <?=select_rating($a1[rating]);?>
<?=$message2?>
<? require_once("admin_footer.php"); ?>[/php]

If you use global vars such as $_POST, $_GET inside double quotes you need to concatenate them such as “.$_POST’varname’].”

Thanks. I tried it another way and I managed to get it to work. I used ‘".mysql_real_escape_string ($_POST[review_text])."’ When I tried before I had made a typo in the line and that’s why is didn’t work.

Thanks again for your help.

Sponsor our Newsletter | Privacy Policy | Terms of Service