Jump to content

not sure what has happened with codes


rdkd1970

Recommended Posts

I am not sure what is going wrong but I have not changed any of my codes and now I am getting this error message on a simple form that I am testing. Any idea what has happened. I have had several successful tries that have updated to the db.

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ebermy5'@'localhost' (using password: NO) in /home/ebermy5/public_html/form.php on line 20

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/ebermy5/public_html/form.php on line 20

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/ebermy5/public_html/form.php on line 21

 

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ebermy5'@'localhost' (using password: NO) in /home/ebermy5/public_html/form.php on line 29

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/ebermy5/public_html/form.php on line 29

 

 

This is the form

 

<?php
@include_once ("Connections/connect_to_mysql.php")
or die('could not connect to database');

  $err='';

  if($_POST["submit"]){
  
    // Validate form data

    if($_POST["firstname"]=='') $err.='Please enter First Name<br>';
    if($_POST["email"]=='') $err.='Please enter Email<br>';



    if($err==''){ 

      // Check if there are duplicate entries in the 'contacts' table

      $results = mysql_query("SELECT id FROM `Members` WHERE firstname='".addslashes($_POST["firstname"])."' and Email='".addslashes($_POST["email"])."'");
      if($row = mysql_fetch_array($results)){
        $err.='Can not add duplicate entry<br>';
      }
      else{

        // adding new record to 'contacts' table

        mysql_query("INSERT INTO Members (firstname,lastname,country,Email) 
                    values ('".addslashes($_POST["firstname"])."','".addslashes($_POST["lastname"])."','".addslashes($_POST["country"])."','".addslashes($_POST["email"])."')");

       // redirecting to success screen
    exit;
      }
    }
  }

?>

The HTML below..

<html>
<head>
<title>Add New Contact</title>
</head>

<body>

<h2>Register with us</h2>

<?php echo $err==''?'''<p style="color:red;">'.$err.'</p>') ?>

<form method="post" action="form.php">

<table border="0">
<tr>
<td valign="middle">First Name:</td>
<td><input type="text" name="firstname" size="30" value="<?php echo htmlspecialchars($firstname) ?>"></td>
</tr>
<tr>
<td valign="middle">Last Name:</td>
<td><input type="text" name="lastname" size="30" value="<?php echo htmlspecialchars($lastname) ?>"></td>
</tr>
<tr>
<td valign="middle">Country:</td>
<td><input type="text" name="country" size="30" value="<?php echo htmlspecialchars($country) ?>"></td>
</tr>
<tr>
<td valign="middle">Email:</td>
<td><input type="text" name="email" size="30" value="<?php echo htmlspecialchars($email) ?>"></td>
</tr>
</table><br>

<input type="submit" name="submit" value=" Submit! ">

</form>

</body>
</html>

Link to comment
Share on other sites

Your mysql_query() statement is attempting to create a connection to the database server, because your actual code that is supposed to be making that connection is failing.

 

What is in your Connections/connect_to_mysql.php file? xxxxx out your username and password, but don't change anything else when you post the code. Post the opening php tag that is in that file as well.

Link to comment
Share on other sites

<?php

// Place db host name. Sometimes "localhost" but

// sometimes looks like this: >>      ???mysql??.someserver.net

$db_host = "localhost";

// Place the username for the MySQL database here

$db_username = "xxxxx";

// Place the password for the MySQL database here

$db_pass = "xxxx";

// Place the name for the MySQL database here

$db_name = "ebermy5_bermy";

// Place the port for the MySQL database here

$mysql_connection_port = "3306";

 

set_time_limit(0);

 

// Run the connection here

$link = mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql");

$link = mysql_select_db("$db_name") or die ("Query died:");

$link = $mysql_connection_port = "3306";

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.