1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

wamp server create database robinsnest;

Discussion in 'PHP' started by gether, Jul 5, 2013.

  1. #1
    i installed wamp server .. and created a database following a tutorial in this robin nixon book called learning php mysql and javascript ..

    please help me arrange it in a correct manner so that i can make my example scripts work ...
    [​IMG]
     
    Last edited: Jul 5, 2013
    gether, Jul 5, 2013 IP
  2. gether

    gether Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #2
    this is what happened when i tried to create a new database with mysql console ..

    create database mynewdatabase;

    a folder with name mynewdatabase appeared here
    [​IMG]

    and a file inside it called db.opt ...

    and somewhere i read that you have to export some file setting from wamp phpmyadmin in the form of localhost.sql

    do i have to rename that file to

    mynewdatabase.sql

    robinsnest.sql

    and do i have to put it in the www folder ?
     
    gether, Jul 6, 2013 IP
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #3
    While not familair with the book, if you are screwing around in the mysql directory just to run some php/mysql, you are doing things ALL WRONG. You have NO business even going into that directory if you just want to run some php that calls a mysql database you already created!

    You created the database, have you assigned a user to it? What exactly is the code you are trying to call that database WITH? You should just be able to plug in the database name, username, password, hostname into the PHP and away you go.

    Though with WAMP (I use XAMPP) you may have to use sockets if you are using PDO? Is that book teaching you to use the deprecated mysql_ functions we've been told for EIGHT YEARS to stop using (and that they now added giant red warning boxes to the manual further pushing that agenda) or is it trying to use mysqli or PDO. (all three have different connection methods)...

    if it is trying to say to use mysql_connect, throw that book in the trash, it's decade out of date insecure rubbish.
     
    deathshadow, Jul 6, 2013 IP
  4. gether

    gether Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #4
    [​IMG]

    in it .. there is a script .. that asks for ...

    database host
    database name
    database user
    database password

    i am not sure if i am doing it right ...
     
    gether, Jul 6, 2013 IP
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #5
    I really think you've completely failed to grasp how mysql even works -- you don't copy or rename a blasted thing!

    What you are asking, doing, and showing is just gibberish. That's not how any of this works... not even certain where to begin explaining HOW it works you are SO far off the mark with this.
     
    deathshadow, Jul 6, 2013 IP
  6. gether

    gether Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #6
    how do you arrange the html form .. the php script ... and the mysql database and table

    for the http server ?
     
    gether, Jul 6, 2013 IP
  7. ryan_uk

    ryan_uk Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #7
    I am trying to understand the problem. You have made the script files and databases as per the book, but the scripts aren't working? If so, paste the error message. It's probably like deathshadow mentioned earlier that the functions you are trying to use are deprecated.
     
    ryan_uk, Jul 6, 2013 IP
  8. gether

    gether Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #8
    ok.. so the mysql files has to be simply inside the wamp folder ? not exactly in the www folder ?
     
    gether, Jul 6, 2013 IP
  9. ryan_uk

    ryan_uk Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #9

    No, MySQL runs as what is called a service, a piece of software "listening". It's like someone who listens for specific questions and responds to them with answers. So, you have MySQL running (listening) and use PHP to talk to it (ask the question) and MySQL responds (answers the question).

    For example:

    Mr PHP Script: "What are all the cities with street called Gator Avenue?"
    Mr MySQL Database: "The cities are Umpa Lumpa, Gumptydon and Sniffleborg."
    Mr PHP Script: "Hi everyone, the cities with Gator Avenue are: ..."

    Understand?

    Firstly, I think you need to understand PHP more. Make sure you can do "Hello World" AND manipulate the text in different ways. I am afraid to write technical terms, as you might get confused, but you need to understand the following:
    • Understand what variables are.
    • Add numbers in PHP.
    • Remove characters from a string.
    • Learn what an array is.
    • Make an array (such as "hello" and "world") and print the text out from it.
    Just as a start before you go on to anything trickier.
     
    ryan_uk, Jul 6, 2013 IP
  10. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #10
    The mysql files should stay where they are, you don't move a blasted thing... though... ok, clarify this for me...


    All those .php files, where did they even come from?

    When you 'create database' it makes the database in mysql's directory, to access it from php you EDIT the .php files so that the name, username, etc are in the code so it can call it.

    I'm not sure where that .sql even came from or what you are supposed to do with it, but if you got this far from a book and ended up this screwed up... I've got the feeling that's a really BAD book.
     
    deathshadow, Jul 6, 2013 IP
  11. gether

    gether Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #11
    ok this is what i have been doing ...

    i installed wamp ...

    took a few script from the book...

    i used the mysql console to create a database

    create database robinsnest;
    create database mynewdatabase;

    use robinsnest;
    use mynewdatabase;

    create table tablename
    create table tablenametwo


    i wanted to see where it was created .. found a folder called robinsnest and mynewdatabase with a db.opt file in both of it ...

    now i guess i can start filling these in one of the scripts

    database host
    database name
    database user
    database password
     
    gether, Jul 6, 2013 IP
  12. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #12
    You'll also need to create a user for that database, unless you plan on logging in as root without a password.
     
    deathshadow, Jul 6, 2013 IP
  13. ryan_uk

    ryan_uk Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #13
    Yes, in one of the scripts, leave your database files alone. Either "talk" to MySQL through its "command line" or use an interface such as phpMyAdmin. As deathshadow mentioned, you'll need a user for the database:
    http://dev.mysql.com/doc/refman/5.1/en/create-user.html

    And grant privileges:
    http://dev.mysql.com/doc/refman/5.1/en/grant.html

    Honestly, I think you should get a better book, mate. Or find a good tutorial online.
     
    ryan_uk, Jul 6, 2013 IP
  14. gether

    gether Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #14
    you know this is something i can keep working on if i can find enough time ...
    i even had plans to extend that to a shopping cart ...


    [​IMG]

    [​IMG]


    [​IMG]

    [​IMG]
     
    Last edited: Jul 6, 2013
    gether, Jul 6, 2013 IP
  15. ryan_uk

    ryan_uk Illustrious Member

    Messages:
    3,983
    Likes Received:
    1,022
    Best Answers:
    33
    Trophy Points:
    465
    #15
    Why don't you just use a premade CMS such as Drupal, OpenCart or one of the many other systems out there that can be used for eCommerce?
     
    ryan_uk, Jul 6, 2013 IP