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
https://forums.phpfreaks.com/topic/248783-php-with-sql-help/
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
https://forums.phpfreaks.com/topic/248783-php-with-sql-help/#findComment-1278280
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.