Help me with my coding

db , php Malaysia
  • 11 years ago

    hey everyone.. I kidda need guidance with my codes.. do you think you can help me?

    <html>
    <?php
    //Step 1 : connect to database
    $server = "localhost";
    $user = "root";
    $password = "";
    $db = "mydb";





     $conn = mysqli_connect($server,$user,$password,$db)

     or die("could not connect to the database!");

     echo "successful connected!";
     
    $textname = $_POST['name'];
    $textnumber = $_POST['number'];
    $textemail_add = $_POST['email_add'];
    $textsubject = $_POST['subject'];
    $textcomment = $_POST['comment'];





    mysql_query("INSERT INTO `mail` VALUES ('$textname', '$textnumber',' $textemail_add', '$textsubject', '$textcomment' )") ;

    mysql_select_db("mydb", $con);  

     echo "Data successfully updated.Thank you very much or your cooperation.";
    ?>

    And here wat the server say,

    successful connected!
    Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\try2.php on line 21

    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\try2.php on line 21

    Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\try2.php on line 23
    Data successfully updated.Thank you very much or your cooperation.





    What should i do? Need help fast!!

    thanx

    -bostbomb-

  • 11 years ago
    hey, try and remove the "i" from the mysql_connect syntax. mysqli is a different db i think

    failing that

    here's the function i use, hasn't failed me yet

    when you go to make a query, just say

    dbConnect();

    in your php syntax, and you should be good to go.

    $dbhost = "supercoolserver";
    $dbuser = "supercooluser";
    $dbpass = "supercoolpassword";

    function dbConnect() {
       global $dbhost, $dbuser, $dbpass;
           $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
           or die("The site database appears to be down.");
     
       return $dbcnx;
    }


    you don't necessarilty need to specify a database, but in your query just add it, so if your "schema" is called "data" then your query will be

    "INSERT INTO data.mail VALUES ('$textname', '$textnumber',' $textemail_add', '$textsubject', '$textcomment' );"




























  • 11 years ago

    hey thanx for the post and i learn something new..

    just wondering do you know how to do number and email verification? because i finally made the form but.... i need to verify whether what the user key in is the correct number or email... do you know how can i do that?

  • 11 years ago
    as in you want to know if the email is valid? like not something made up?  

  • 11 years ago
    and did you ever get the actual first thing to work? was that the probelm?  

  • 11 years ago

    yup i need to know how to verified the email making sure it is an email not just some words..

    and yes the first thing did work.

    thank u.

  • 11 years ago

    can asp lang be use for php?

    are they the same? similar? quite similar?

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“XML is like violence - if it's not working for you, you're not using enough of it.”