SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a problem:

    Have a look at

    http://216.74.101.27/test.php

    Now, either it is not working because the name hasn't been transfered yet or i have something wrong.

    I am just copying the article supplied at Sitepoint to test MySQL out:


    <HTML><HEAD><TITLE> Our List of Jokes </TITLE><HEAD><BODY>

    <?php
    $cnx = mysql_connect( "216.74.101.27", "*****", "*****");
    if (!$cnx) {
    echo( "<P><B>Unable to connect to the database server at this time.</B></P>" );
    exit();}


    mysql_select_db("petesmc_articles", $cnx);
    if (! @mysql_select_db("petesmc_articles") ) {
    echo( "<P>Unable to locate the joke database at this time.</P>" );
    exit();}

    if (! @mysql_select_db("petesmc_articles") ) {
    echo( "<P>Unable to locate the joke database at this time.</P>" );
    exit(); }
    ?>

    <P> Here are all the jokes in our database: </P><BLOCKQUOTE>

    <?php // Request the text of all the jokes
    $result = mysql_query("SELECT JokeText FROM petesmc_articles");
    if (!$result) {
    echo("<P>Error performing query: " . mysql_error() . "</P>");
    exit(); }

    // Display the text of each joke in a paragraph
    while ( $row = mysql_fetch_array($result) ) {
    echo("<P><table width=50% border=3 bordercolor=blue><tr><td>" . $row["JokeText"] . "</td></tr></table></P>"); }
    ?>

    </BLOCKQUOTE></BODY></HTML>





    Any ideas?

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change
    $cnx = mysql_connect( "216.74.101.27", "*****", "*****");
    to
    $cnx = mysql_connect( "localhost", "*****", "*****");

    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx allot.

    I got it working.

  4. #4
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you rename a databse from telnet?

  5. #5
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not really you could use mysqldump to dump the tables to a text file then create a new database an import the tables back in

    Step 1:

    cd into the directory use
    $> mysqldump -u username -p > db.sql

    Step 2:

    $> mysqladmin -u username -p CREATE dbname

    Step 3:

    $> mysql -u username -p newdbname < db.sql


    Chenge username to be your username

    NOTE: this will only work if you have rights to create databases
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  6. #6
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For some reason this doesn't work, same URL
    ----------

    <HTML><HEAD><TITLE> Our List of Jokes </TITLE><HEAD><BODY><basefont face="verdana"><font size="2">
    <?php
    if (isset($addjoke)):?>
    <FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST>
    <P>Type your joke hereBR>
    <TEXTAREA NAME="joketext" ROWS=10 COLS=40 WRAP></TEXTAREA>
    <BR><INPUT TYPE=SUBMIT NAME="submitjoke" VALUE="SUBMIT"></FORM>
    <?php else:
    $dbcnx = @mysql_connect("localhost", "petesmc_peabug", "setcookie");
    if (!$dbcnx) {
    echo( "<P>Unable to connect to the database server at this time.</P>" );
    exit(); }
    if (! @mysql_select_db("petesmc_articles") ) {
    echo( "<P>Unable to locate the joke database at this time.</P>" );
    exit(); }
    if ("SUBMIT" == $submitjoke) {
    $sql = "INSERT INTO Jokes SET JokeText='$joketext', JokeDate=CURDATE()";
    if (mysql_query($sql)) {
    echo("<P>Your joke has been added.</P>"); }
    else {
    echo("<P>Error adding submitted joke: " . mysql_error() . "</P>"); }
    }
    echo("<P> Here are all the jokes in our database: </P>");
    $result = mysql_query("SELECT JokeText FROM Jokes");
    if (!$result) {
    echo("<P>Error performing query: " . mysql_error() . "</P>");
    exit(); }
    while ( $row = mysql_fetch_array($result) ) {
    echo("<P>" . $row["JokeText"] . "</P>");
    }
    while ( $row = mysql_fetch_array($result) ) {
    echo("<P><table width=50% border=3 bordercolor=blue cellpadding=0 cellspacing=0><tr><td><blockquote><br>" . $row["JokeText"] . "</blockquote></td></tr></table></P>"); }
    ?>
    </font></body></html>


    ---------

  7. #7
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    CD to what DIR, would SQL be on the same server?

  8. #8
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    to whatever dir it really doesn't matter yes MySQL should be running on the same server since you can connect to localhost
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  9. #9
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would download phpMyAdmin to rename a database. It's basically a web-based interface to connect to your mySQL database. I'm new at this too and this program came in handy.

    <///////~

    www.sohh.com

  10. #10
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have phpAdmin but i can't seem to rename

  11. #11
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am pretty darn sure that PHPMyAdmin cannot perform functions that MySQL cannot!
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  12. #12
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My mistake. phpMyAdmin will only let you rename tables, not the name of the database.

  13. #13
    SitePoint Evangelist
    Join Date
    Jul 2000
    Location
    Warwickshire, England
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As I posted earlier, you can simply rename the directory in which the database is contained. (You may have to reset the permissions on that directory).
    E.g. to rename "foo" to "bar", you would rename the folder "foo" to "bar" in your data dir in telnet.

  14. #14
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now what about the entries in your mysql table for users or hosts who have access to a specific database, you would need to change those as well. I think one should always avoid just changing the name of the data dir.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •