MySql To Web ?

Discussion in 'MySQL' started by LemonAden, Aug 30, 2006.

  1. #1
    Morning everyone. Here at my job we figured out how to put import our sql queries into our MySql on our webhost. (hostgator.com).

    Now what i need to do is find a program or script that will take our Mysql databse and generate it into a webpage that our clients can go to and search the database.

    No photos, nothing crazy, just a database so when they search they will see the number of that particular item line we have in stock. Any suggestions?

    I am hoping that there is a small script or program, anything, that i can use for this. Please help, i have a deadline to meet by the end of the day and this is all new to me.. Its something that are hoping i can learn for them for future projects. Thank you!
     
    LemonAden, Aug 30, 2006 IP
  2. ahkip

    ahkip Prominent Member

    Messages:
    9,205
    Likes Received:
    647
    Best Answers:
    0
    Trophy Points:
    310
    #2
    if you customer know mysql query, then just create a html form with field database_name, user_name, password and the query. Then a php page to connect to database, run the query and display result
     
    ahkip, Aug 30, 2006 IP
  3. LemonAden

    LemonAden Peon

    Messages:
    308
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ive got the PHP side down.. i am having trouble connecting, but that is somethign i will talk with out host provider later on about.. I am using in PHP:

    <?php
    $dbh=mysql_connect ("74.52.59.162", "ras_client", "<*****>") or die ('I cannot connect to the database because: ' . mysql_error());
    mysql_select_db ("ras_test");
    ?>




    Now what about the HTML part you are talking about.. how do i do that?
     
    LemonAden, Aug 30, 2006 IP
  4. ahkip

    ahkip Prominent Member

    Messages:
    9,205
    Likes Received:
    647
    Best Answers:
    0
    Trophy Points:
    310
    #4
    try to use localhost instead of 74.52.59.162 at the mysql_connect ...
     
    ahkip, Aug 30, 2006 IP
  5. LemonAden

    LemonAden Peon

    Messages:
    308
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    i am getting this message every time i try to connect.. wether i use localhost or the IP:


    Warning: mysql_connect(): Access denied for user 'ras_client'@'localhost' (using password: YES) in /home/ras/public_html/curtis/temptemp.php on line 8
    I cannot connect to the database because: Access denied for user 'ras_client'@'localhost' (using password: YES)
     
    LemonAden, Aug 30, 2006 IP
  6. ahkip

    ahkip Prominent Member

    Messages:
    9,205
    Likes Received:
    647
    Best Answers:
    0
    Trophy Points:
    310
    #6
    ok, i believe you created the database and user ras_client, right? but did you grand the privilege to ras_client for the temptemp database?
     
    ahkip, Aug 30, 2006 IP
  7. LemonAden

    LemonAden Peon

    Messages:
    308
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #7
    yes. i granted permissions for ras_client to the ras_test database. Still nothing is working.

    Im sorry for being a noob at this. I am still learning.
     
    LemonAden, Aug 30, 2006 IP
  8. LemonAden

    LemonAden Peon

    Messages:
    308
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #8
    We found the problem..

    its because i had the password between these <****> .. Now the link works but its bringing up a blank page.

    Does anyone know how i get this page to show the database?
     
    LemonAden, Aug 30, 2006 IP
  9. ahkip

    ahkip Prominent Member

    Messages:
    9,205
    Likes Received:
    647
    Best Answers:
    0
    Trophy Points:
    310
    #9
    if you can wait till lunch time (around 12:30 est) i can help you with the displaying part. I am at work now
     
    ahkip, Aug 30, 2006 IP
  10. LemonAden

    LemonAden Peon

    Messages:
    308
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #10
    i will be here from now 11:30 EST to 1:00pm. Then i will be back at 2:est, and be here until 4:30.

    Your help is so arreciated, you have no idea!

    someone told me to use this on the php page to make the database show on the page... i put it in there, but its not working :)


    <?php
    $query = "SELECT * FROM table
    $result = mysql_query($query); //or die(mysql_error() . '<br>' . $sql);
    echo "<table>";
    while($row = mysql_fetch_array($result))
    {
    echo "<tr><td>$row[product id]</td><td>$row[quantity]</td></tr>";
    }
    echo "</table>";
    ?>
     
    LemonAden, Aug 30, 2006 IP
  11. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #11
    I think you need to mention the name of the table you want to "SELECT".
    Try this code:
    Replace the "Type your database table name here" with actual table name. Do not remove the "" marks.
    <?php
    $table= "Type your database table name here";
    $query = "SELECT * FROM $table";
    $result = mysql_query($query); //or die(mysql_error() . '<br>' . $sql);
    echo "<table>";
    while($row = mysql_fetch_array($result))
    {
    echo "<tr><td>$row[product id]</td><td>$row[quantity]</td></tr>";
    }
    echo "</table>";
    ?>
    That should display your entire database...
    Bye :D
     
    JEET, Aug 30, 2006 IP