Jump to content

Recommended Posts

$dbc = mysql_connect ($db_server, $db_user, $db_pass);
mysql_select_db ($db_name) or die(mysql_error());

$rs = mysql_query("SELECT b_id, b_text FROM rate_blogs");
if($rs) {
while($row = mysql_fetch_assoc($rs)) {

       $decode = unserialize(base64_decode($row['b_text']));      
       $b_text = $decode[];

       mysql_query ("UPDATE rate_blogs SET
                    b_untext = '$b_text',
                    WHERE b_id = '".$row['b_id']."'");
}                     
}

echo "Done";

Link to comment
https://forums.phpfreaks.com/topic/151109-does-this-look-correct/
Share on other sites

Echo your variables to verify where it's failing.

 

i just tried that actually I tried that and its echo'ing that data. do you think it's because i'm doing an Update and should be doing INSERT since that new fields are all blank?

 

if so would this INSERT command work

 

        mysql_query ("INSERT INTO rate_blogs VALUES b_untext = '$b_text' WHERE b_id = '".$row['b_id']."'");

Echo your variables to verify where it's failing.

 

i just tried that actually I tried that and its echo'ing that data. do you think it's because i'm doing an Update and should be doing INSERT since that new fields are all blank?

 

if so would this INSERT command work

 

        mysql_query ("INSERT INTO rate_blogs VALUES b_untext = '$b_text' WHERE b_id = '".$row['b_id']."'");

 

No.

 

Add or die(mysql_error());  to the end of your queries and see if there are any errors;

Echo your variables to verify where it's failing.

 

i just tried that actually I tried that and its echo'ing that data. do you think it's because i'm doing an Update and should be doing INSERT since that new fields are all blank?

 

if so would this INSERT command work

 

        mysql_query ("INSERT INTO rate_blogs VALUES b_untext = '$b_text' WHERE b_id = '".$row['b_id']."'");

 

No.

 

Add or die(mysql_error());  to the end of your queries and see if there are any errors;

 

Parse error: syntax error, unexpected T_STRING in /rate_blog.php on line 19

which is the first line of this statement

 

        mysql_query ("UPDATE rate_blogs SET

                    b_untext = '$b_text',

                    WHERE b_id = '".$row['b_id']."'");

You have a comma right before the WHERE clause, remove it.

 

EDIT: The comma doesn't exists 2 posts ago but your most recent it does, which one is it?

 

If there really is no comman, then use this:

 

  mysql_query("UPDATE rate_blogs SET b_untext = '$b_text' WHERE b_id = '{$row['b_id']}') or die(mysql_error());

You have a comma right before the WHERE clause, remove it.

 

EDIT: The comma doesn't exists 2 posts ago but your most recent it does, which one is it?

 

If there really is no comman, then use this:

 

  mysql_query("UPDATE rate_blogs SET b_untext = '$b_text' WHERE b_id = '{$row['b_id']}') or die(mysql_error());

same error Parse error: syntax error, unexpected T_STRING in /rate_blog.php on line 26

 

the comma i had in the 2nd post was because the sql statement was on 3 lines. i just tried it on one line and got the same error

i tried this code in my php IDE and it came back clean, but when I run it I'm giving the same error.

mysql_query("UPDATE rate_blogs SET b_untext = $b_text WHERE b_id = $row[b_id]") or die(mysql_error());

 

some users have html coding inside the b_text could that be the problem?

this is working but with an error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE b_id = 4' at line 1


$dbc = mysql_connect ($db_server, $db_user, $db_pass);
mysql_select_db ($db_name) or die(mysql_error());

$rs = mysql_query("SELECT b_id, b_text FROM rate_blogs") or die(mysql_error());
if($rs) {
while($row = mysql_fetch_assoc($rs)) {


//$b_text = $row['b_text'];   
//        echo $row['b_text'];
        $decode = unserialize(base64_decode($row['b_text']));  
//        echo $decode;    
        $b_text =	$decode;
        
//        mysql_query ("UPDATE rate_blogs SET
//                     b_untext = '$b_text',
//                     WHERE b_id = '".$row['b_id']."'");
  mysql_query("UPDATE rate_blogs SET b_untext = $b_text WHERE b_id = $row[b_id]") or die(mysql_error());
}                     
}

echo "Done";

same error.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE b_id = 4' at line 1

 

$dbc = mysql_connect ($db_server, $db_user, $db_pass);
mysql_select_db ($db_name) or die(mysql_error());

$rs = mysql_query("SELECT b_id, b_text FROM rate_blogs") or die(mysql_error());
if($rs) {
while($row = mysql_fetch_assoc($rs)) {


//$b_text = $row['b_text'];   
//        echo $row['b_text'];
        $decode = unserialize(base64_decode($row['b_text']));  
//        echo $decode;    
        $b_atext =	mysql_real_escape_string($decode);

$b_text = addslashes($b_atext);
//        mysql_query ("UPDATE rate_blogs SET
//                     b_untext = '$b_text',
//                     WHERE b_id = '".$row['b_id']."'");
  mysql_query("UPDATE rate_blogs SET b_untext = $b_text WHERE b_id = $row[b_id]") or die(mysql_error());
}                     
}

echo "Done";

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.