I am new and need advice.

Discussion in 'MySQL' started by Mitchell, Jun 21, 2009.

  1. #1
    I have Windows XP, PHP, Apache, MySQL and phpMyAdmin installed and working.

    I am just learning about databases using phpMyAdmin. I am following examples in a couple of books. The examples show me how to create and populate a table with information that is just a few simple words or sentences long like a record of form data.

    For example. 1. Name, address, phone number, email, etc.
    2. Name, address, phone number, email, etc.
    3. Name, address, phone number, email, etc.
    4. Name, address, phone number, email, etc.

    However, the kind of information I am trying to build a database for are paragraphs of code like HTML that has its own unique structure that is not easily divided into a series of compartments or numbered cells.

    Is it possible to create just one cell to store and retrieve a page of HTML or other code?

    What is the best way to go about handling information such as a page of HTML or other such code with there tags, functions and other details?

    Is there a book or tutorial that addresses this specific issue?

    Thanks for any advice.
     
    Mitchell, Jun 21, 2009 IP
  2. Social.Network

    Social.Network Member

    Messages:
    517
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    35
    #2
    Yes. Many content management systems and blog platforms store HTML in the database.

    For example, WordPress stores the post content (including HTML) in the wp_posts table.

    Focus on concepts and apply as needed to meet requirements. http://tinyurl.com/bvk5x
     
    Social.Network, Jun 22, 2009 IP
  3. ironmanv8

    ironmanv8 Active Member

    Messages:
    211
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Mitchel,

    Within the phpMyAdmin that you are using, you can set what data type each column is--and all the cells that are underneath that column will be data of that data type. For stuff like names, titles, etc., I recommend VARCHAR. For the actual article itself, I would recommend looking at setting it as a BLOB or TEXT. Also, something else you need is some kind of primary key or ID that is auto incremented. The ID column is typically the first column set as an INT data type and it is set to auto-increment.

    I hope this helps with your learning of MySQL. Feel free to PM me or ask here if you have any questions.
     
    ironmanv8, Jun 22, 2009 IP
  4. Mitchell

    Mitchell Peon

    Messages:
    204
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks to both of you for your advice.

    After reading through a book at the book store I have been thinking data types might be what I need to learn to make this work.

    In my experiments this symbol ( < ) in my code stored in MYSQL database is preventing the rest of the code from being retrieved from the database table.

    I have read that the string data type excepts all characters; However there seems to be more than one type of string data type. It has not worked for me yet. I will try BLOB and TEXT.

    I think I have narrowed my book choice down to two and I am going to read up on data types and try this again.

    Thanks again. I will do as you suggest.
     
    Mitchell, Jun 22, 2009 IP
  5. chisara

    chisara Peon

    Messages:
    141
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I think you are being bitten by special characters
    Are you supplying your input to the query using parameters ? Then the database special character encoding is done for you.
    If your system can't do that you can use a Db specific function to escape special characters for your database server (escape special characters/entities).
    If you are building your query using $query="INSERT INTO mytable values(" + $INPUTSTRING); then you can get problems with special characters in your input to the database, unless the PHP generic input mangler (MAGIC_QUOTES) is active. Then PHP takes the liberty to fuckup your input data in the hope that it covers all special characters of your storage system.
     
    chisara, Jun 23, 2009 IP
  6. Mitchell

    Mitchell Peon

    Messages:
    204
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks chisara.

    Everything you said is too advanced for me to understand at the moment, but it sounds like you may of found the source of my problem.

    I copied what you said to my hard drive for future reference. As I read some books on PHP and MYSQL I will try to expand my knowledge in the direction you suggest.
     
    Mitchell, Jun 23, 2009 IP
  7. gauravajitsaria

    gauravajitsaria Peon

    Messages:
    309
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    if ur facing problems with "<" and ">" signs only,
    then u can scan the document that u want to enter in the database and replace them with &lt and &gt.
    it works
     
    gauravajitsaria, Jun 24, 2009 IP
  8. Mitchell

    Mitchell Peon

    Messages:
    204
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Your right. It works, as long as I leave a space between < name >; Compared to <name>.
     
    Mitchell, Jun 24, 2009 IP
  9. ironmanv8

    ironmanv8 Active Member

    Messages:
    211
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #9
    Mitchel,

    While you are working with the database stuff, there are tools out there that are more powerful than phpMyAdmin. These tools allow you to connect directly from your computer to the database server.

    I would recommend trying MySQL Administrator:
    http://dev.mysql.com/downloads/gui-tools/5.0.html
     
    ironmanv8, Jun 24, 2009 IP
  10. Mitchell

    Mitchell Peon

    Messages:
    204
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thanks.

    I was planning on using my own computer as a server, but my plans could change as I learn more. I will check it out.

    What I really need to find out is if there is a way to insert a whole page of information into a field on a table. In phpmyadmin the form section of the GUI where I enter a value is an awkward 3 inches long. That's enough for 3 words. It just seems the form input window should be much larger like the one I am typing on now. All the books I read only show how to input little bits of information like name, address, email, etc.

    Perhaps there is more than one way to input information into a data base.

    Do I use the import tab and bring it in as a seperate file?

    I notice there is an SQL tab, but that form window is still a little small.
     
    Mitchell, Jun 25, 2009 IP
  11. Romocop

    Romocop Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    What guaravana said.
     
    Romocop, Jun 25, 2009 IP