+ Reply to Thread
Page 1 of 4 123 ... LastLast
Results 1 to 10 of 38

Thread: MYSQL help

  1. #1
    xcaliberse is offline x10Hosting Member xcaliberse is an unknown quantity at this point
    Join Date
    Nov 2008
    Posts
    46

    MYSQL help

    Hey, so i created a mysql server, and i jus wanted to make a form that does feedback. so i have this
    <script>
    <?
    $firstname=$_POST['Name'];
    $message=$_POST['Message'];


    $submit=$_POST['submit'];
    if($submit=="Submit"){


    $con = mysql_connect("heres the problem","username,"password");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db("learning_beta", $con);

    mysql_query("INSERT INTO Persons (Name, Message)
    VALUES ('$firstname', '$lastname')");

    echo "DONE";
    }

    ?>

    <form method="post">
    Firstname: <input type="text" name="Name"><br />
    Message: <input type="text" name="Message"> <br />
    <input type="submit" name="submit" value="Submit">
    </form>
    </script>

    The problem is, how do i know what the login is? i have hte user name and password but iono the site for the phpMyAdmin login or whatever its suppsoed to be.

  2. #2
    tittat's Avatar
    tittat is offline x10 Spammer tittat is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Kerala,India
    Posts
    2,479

    Re: MYSQL help

    ******Thread Moved to programming Help******
    PLAY ONLINE GAMES
    WWW.TMONDO.COM PlayFar Flash Games
    Former X10 Forum Senior Moderator(Retired)


  3. #3
    xcaliberse is offline x10Hosting Member xcaliberse is an unknown quantity at this point
    Join Date
    Nov 2008
    Posts
    46

    Re: MYSQL help

    bump

  4. #4
    vol7ron's Avatar
    vol7ron is offline x10 Lieutenant vol7ron is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    DC
    Posts
    434

    Re: MYSQL help

    you bumped a thread after being moved 3 mins earlier? haha


    it's going to be 'localhost' or possibly 'localhost:5432'


    don't forget that your db and username have your x10name in front of it:
    xcaliberse_dbname
    xcaliberse_username
    mySQLpw
    Last edited by vol7ron; 12-17-2008 at 09:52 AM.
    If you find my post useful please add to my reputation by clicking the +Rep button
    You may also use the Donate link to donate credits - this is appreciated too Thanks to those whom have donated so far!


  5. #5
    xcaliberse is offline x10Hosting Member xcaliberse is an unknown quantity at this point
    Join Date
    Nov 2008
    Posts
    46

    Re: MYSQL help

    I dont think "localhost:5432" or "localhost" is the appropriate thing to use for the mysql hosting link. The link should lead u directly to the phpMyAdmin login page, but any link i try just gets me directly to the control panel login.

  6. #6
    infurTH is offline x10Hosting Member infurTH is an unknown quantity at this point
    Join Date
    Oct 2008
    Posts
    44

    Re: MYSQL help

    it is bump and it is localhost

  7. #7
    xcaliberse is offline x10Hosting Member xcaliberse is an unknown quantity at this point
    Join Date
    Nov 2008
    Posts
    46

    Re: MYSQL help

    So for

    $con = mysql_connect("heres the problem","username,"password");

    I put "localhost" for "heres the problem"? or no?

  8. #8
    vol7ron's Avatar
    vol7ron is offline x10 Lieutenant vol7ron is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    DC
    Posts
    434

    Re: MYSQL help

    If you're trying to access MySQL through your code, then yes. <you could have tested it by now>

    If you're trying to get to phpMyAdmin, then no. But you're not going to be managing MySQL through phpMyAdmin in your code. You cannot connect to phpMyAdmin using mysql_connect() ~ that's absurd, MySQL is a database, phpMyAdmin is an application to interface the database.

    Just use localhost and you will see.
    Last edited by vol7ron; 12-17-2008 at 03:36 PM.
    If you find my post useful please add to my reputation by clicking the +Rep button
    You may also use the Donate link to donate credits - this is appreciated too Thanks to those whom have donated so far!


  9. #9
    xcaliberse is offline x10Hosting Member xcaliberse is an unknown quantity at this point
    Join Date
    Nov 2008
    Posts
    46

    Re: MYSQL help

    Ok heres my new code

    <?
    $firstname=$_POST['Name'];
    $message=$_POST['Message'];


    $submit=$_POST['submit'];
    if($submit=="submit"){


    $con = mysql_connect("localhost","username","password");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db("learning_beta", $con);

    mysql_query("INSERT INTO Persons (Firstname, Message)
    VALUES ('$firstname', '$message')");

    echo "DONE";
    }

    ?>

    <form method="post">
    Firstname: <input type="text" name="Name"><br />
    Message: <input type="text" name="Message"> <br />
    <input type="submit" name="submit" value="Submit">
    </form>

    Okay even if i type in jdkas;lfe instead of localhost, it doesnt give me the die(...); error. And it doesnt save it into the table that i made using phpMyAdmin. Can someone help me? I even manually added something via phpMyAdmin to the table and it doesnt show on the site. its www.kevinliang.x10hosting.com/feedback.php thanks.

  10. #10
    crisp is offline x10Hosting Member crisp is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    85

    Re: MYSQL help

    In you're script
    Code:
    if($submit=="submit"){
    is always going to evaluate to false, because, in your form, the value for submit is "Submit" not "submit". Thus, the db connect and subsequent insert isn't ever going to happen.

    Try replacing that line with this instead
    Code:
    if ($submit=="Submit") {
    or even
    Code:
    if (strtolower($submit)=="submit") {
    and as previously stated by others, localhost is what you should be using for the host name to connect to the db ;)

+ Reply to Thread
Page 1 of 4 123 ... LastLast

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. Which is better postgresql or MySQL?
    By Kurai Kumo in forum Scripts & 3rd Party Apps
    Replies: 11
    Last Post: 12-10-2009, 08:17 AM
  3. Replies: 14
    Last Post: 09-29-2008, 07:07 PM
  4. New Site-Suggestions?
    By mnoutside in forum Review My Site
    Replies: 9
    Last Post: 08-27-2008, 07:01 AM
  5. Have a problem with my forum
    By tikloos in forum Scripts & 3rd Party Apps
    Replies: 43
    Last Post: 01-19-2006, 01:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers