Results 1 to 3 of 3

Thread: Alter mysql table/field via php

  1. #1
    Join Date
    Feb 2010
    Location
    Falkirk, Scotland
    Posts
    142
    Thanks
    21
    Thanked 4 Times in 4 Posts

    Default Alter mysql table/field via php

    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!

    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:
    PHP Code:
    <?
    $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?
    Last edited by liamallan; 07-28-2010 at 10:21 AM.

  2. #2
    Join Date
    Feb 2010
    Location
    Falkirk, Scotland
    Posts
    142
    Thanks
    21
    Thanked 4 Times in 4 Posts

    Default

    anyone know?

  3. #3
    Join Date
    Feb 2010
    Location
    Falkirk, Scotland
    Posts
    142
    Thanks
    21
    Thanked 4 Times in 4 Posts

    Default

    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:
    Code:
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •