Jump to content

php with sql help


kabar916

Recommended Posts

Whats going on you guys.  i cant figure out how to use the UPDATE function in php to update a field in sql.  I basically want to remove all the quote symbol ( " ) in a certain field.  This is what how i wrote it.  please let me know where im making the error.

 

<?php

require_once("includes/connection.php");

$result = mysql_query("UPDATE export SET department = REPLACE(department, '\"\','  ')", $connection)

?>

Link to comment
Share on other sites

you could put it in a loop:

$qry = "SHOW COLUMS FROM export";
$loop_result = mysql_query($sql) or die (mysql_error());
$c= 0;
while ($loop_row = mysql_fetch_array($loop_result)){
$field = $loop_row['Field'];
$sql = "UPDATE export SET $field = (REPLACE(department, '\"',' '))";
$update = mysql_query($sql) or die (mysql_error());
$c = $c++;
}
if($c >= 1){
echo "$c Fileds have been successfuly reformated";
}
else{
echo "Operation did not update any rows";
}

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.