Jump to content

does this look correct?


acctman

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
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']."'");

Link to comment
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']."'");

 

No.

 

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

Link to comment
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']."'");

 

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']."'");

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.