Jump to content

trouble deleting column from table


pcw

Recommended Posts

Hi, I have this script which I would like to delete a column from a table. I cant seem to get it right although it gives no errors.

 

case "deletefield":

include_once("data/mysql.php");

$fieldName = $_GET['fieldName'];
$mysqlPassword = (base64_decode($mysqlpword));

$con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error());
mysql_select_db("$dbname", $con) or die(mysql_error());
mysql_query("DELETE FROM profiles WHERE $fields = mysql_num_fields('$fieldName')");

mysql_close($con);

header("Location: admin.php?cmd=profileFields&username=admin");

break;

 

$fieldName is carried to the form correctly, I just cant work out the code for $fields = mysql_num_fields

 

Any help is much appreciated

Link to comment
https://forums.phpfreaks.com/topic/231640-trouble-deleting-column-from-table/
Share on other sites

Hi, thanks for your reply. I tried this and now get these errors:

 

Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource in /home/tropicsb/public_html/MemberSiteMaker/admin.php on line 621

 

Warning: Cannot modify header information - headers already sent by (output started at /home/tropicsb/public_html/MemberSiteMaker/admin.php:621) in /home/tropicsb/public_html/MemberSiteMaker/admin.php on line 624

 

thanks

A DELETE query will delete a ROW from your table.

 

If you want to remove an actual column from your whole table, you would use an ALTER TABLE query.

 

If you want to clear the value in a column in one or more rows in your table, you would use an UPDATE query.

 

What exactly are you trying to accomplish?

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.