www.webdeveloper.com
Results 1 to 8 of 8

Thread: inserting serialized values into fields?

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Location
    London, England
    Posts
    19

    inserting serialized values into fields?

    Hi, I m using,

    PHP Version: 5.2.14
    MySQL Version: 5.0.91

    i would like to insert values 12000 to 14999 into (item_id) field, via phpmyadmin

    tables and fields have been created, i was wondering if some one here could please help me with a sql query to insert 3000 values into a field.

    Im rather new to the managing database, i hope i'm not confusing, here;s what i want,
    HTML Code:
    #TABLE_NAME
    =================================
    #ITEM_ID           #TAG_ID
    =================================
    1                       128
    >                        >
    11999                128
    
    I would like values to be created below these.
    U should've backed up your data.
    http://supermodelsclub.tk/

  2. #2
    Join Date
    Nov 2002
    Location
    NJ, USA
    Posts
    785
    So item ID will be incremented from 12000 to 14999?
    What about tag ID? Would they all have values of 128, or incremented from 129 to 12129? or would they be null or zero?
    Absence of a result is a result, unless defined otherwise.

  3. #3
    Join Date
    Jun 2008
    Location
    London, England
    Posts
    19
    sorry, should have made it clearer,
    # item_id will increment
    # tag_id will remain the same at 128
    U should've backed up your data.
    http://supermodelsclub.tk/

  4. #4
    Join Date
    Dec 2005
    Posts
    2,984
    PHP Script:

    PHP Code:

    $i
    =12000;

      
    $query "insert into `tbl_name` (item_id,tag_id) values";
      
    $q false;
    while(
    $i<14999) {
       
    $q .= (!$q) ? "" ", ";
       
    $q .= "('".$i."','128')";
    }

      
    mysql_insert($query.$q); 
    Last edited by aj_nsc; 05-02-2011 at 03:00 PM.
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...
    awesome.

  5. #5
    Join Date
    Jun 2008
    Location
    London, England
    Posts
    19
    I used the query provided, but I think its not in the right syntax, but then again, i m new to sql.

    HTML Code:
    MySQL said: Documentation
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$i=12000' at line 1
    i should mention, values are being added to the existing table 'ws_items', whhich i have substituted in the query provided.
    U should've backed up your data.
    http://supermodelsclub.tk/

  6. #6
    Join Date
    Dec 2005
    Posts
    2,984
    It's not an SQL query, it's a tiny PHP program that generates an SQL query.
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...
    awesome.

  7. #7
    Join Date
    Nov 2002
    Location
    NJ, USA
    Posts
    785
    ...which means that you will not be using it via phpmyadmin, but rather run it on the server via your web browser. So what you need to do is to create a php file, then within it include the mysql connect portion to connect to the database, then include the snippet provided by aj_nsc, upload it to the server, then physically go to the http://yourdomainname.com/yourscript.php (whatever that may be), and run it that way.
    Absence of a result is a result, unless defined otherwise.

  8. #8
    Join Date
    Jun 2008
    Location
    London, England
    Posts
    19
    okay, i feel sheepish for not realizing that. I'll create a php script and post back how it went. Thank you all for help.
    U should've backed up your data.
    http://supermodelsclub.tk/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles