Log in

View Full Version : Resolved Alter mysql table/field via php



liamallan
07-26-2010, 04:03 PM
hey guys, i have been working on a system to manage my mysql databases (add/alter tables and fields) because for some reason i cant access the control panel or mysql on my hosts site! :mad:

things are going along pretty well with my mysql management system, BUT.......... i created a tutorial system on my site when i could access my hosts cp and mysql, and i made the mistake of making the tutorial field a 'VARCHAR' when it should be 'LONGTEXT'.

i tried doing this:

<?
$db="database";
$link = mysql_connect('localhost', 'username', 'password');
if (!$link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
mysql_query("ALTER TABLE tutorials CHANGE tutorial tutorial LONGTEXT") or die(mysql_error());
echo "Table Changed";
mysql_close($link);
?>

but i still cant insert long tutorials into the table!?

any ideas guys?

liamallan
07-27-2010, 12:03 AM
anyone know? :confused:

liamallan
07-27-2010, 06:48 PM
sorry, the field that needs changed is 'blob' and not 'varchar', got hold of a script to tell me info about my tables, thats when i noticed!

isnt 'blob' used for large amounts of data?
this is the info on my tutorial field:

Information for column 2:
blob: 1
max_length: 3808
multiple_key: 0
name: tutorial
not_null: 0
numeric: 0
primary_key: 0
table: tutorials
type: blob
default:
unique_key: 0
unsigned: 0
zerofill: 0