Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

connect to sql

  • 30-03-2013 8:31am
    #1
    Posts: 0


    44787-creating-loginregistration-forms-with-php

    <?php
    if($_GET["regname"] && $_GET["regemail"] && $_GET["regpass1"] && $_GET["regpass2"] )
    {
    if($_GET["regpass1"]==$_GET["regpass2"])
    {
    $servername="localhost";
    $username="root";


    $conn= mysql_connect($servername,$username)or die(mysql_error());
    mysql_select_db("test",$conn);
    $sql="insert into users (name,email,password)values('$_GET[regname]','$_GET[regemail]','$_GET[regpass1]')";
    $result=mysql_query($sql,$conn) or die(mysql_error());
    print "<h1>you have registered sucessfully</h1>";

    print "<a href='index.php'>go to login page</a>";
    }
    else print "passwords doesnt match";
    }
    else print"invaild data";
    ?>


    Hi guys, trying to connect to a data base and having some trouble. Do I simple just put into the above

    $password="password";

    I have tryed this and I get and error message unable to connect.

    thanks


Comments

  • Registered Users, Registered Users 2 Posts: 1,477 ✭✭✭azzeretti


    Cannot say I know php at all but it looks like you're not passing enough information to your connection function. Shouldn't you need more than server name and username? Password too?


  • Registered Users, Registered Users 2 Posts: 7,041 ✭✭✭Seachmall


    [PHP]$conn = mysql_connect($host,$user,$pass);[/PHP]

    Presumably you need a password to connect to the DB, especially as you're connecting as root.


Advertisement