-3

ユーザーがさまざまな詳細を入力してフォームに送信するphpコードを書いています。しかし、送信すると、次のエラーが表示されます。

警告: mysql_query() [function.mysql-query]: /home/sifeiitd/public_html/wh.php 行 95 で、ユーザー 'sifeiitd'@'localhost' (パスワードを使用: NO) のアクセスが拒否されました

警告: mysql_query() [function.mysql-query]: サーバーへのリンクを /home/sifeiitd/public_html/wh.php 行 95 で確立できませんでした

私のphpコードは

<?php
                //include the connection file

                require_once('functions/connection.php');
                require_once('functions/functions.php');

                $display_query = mysql_query("SELECT * FROM eportal");

                    echo "<table id='pageTable'><thead><tr><th>Item code</th><th>Image</th><th>Description</th><th>Cost</th></tr></thead>";
                    echo "<tbody>";
                    while($row = mysql_fetch_array($display_query)){
                        print "<tr><td>".$row['itemid']."</td><td>"."</td><td>".$row['description']."</td><td>";
                        print "&#8377;".$row['cost']."</td></tr>";
                    }
                    echo "</tbody>";
                    echo "</table>";
                    mysql_close($connection);

            ?>
            <?php

            //save the data on the DB and send the email

            //If the user has submitted the form
            if($_POST['submit']){
                //protect the posted value then store them to variables
                $name = protect($_POST['name']);
                $email = protect($_POST['email']);
                $contact=protect($_POST['contact']);
                $itemid=protect($_POST['itemid']);
                $itemquantity=protect($_POST['itemquantity']);
                $ip = gethostbyname($_SERVER['REMOTE_ADDR']);
                $message = protect($_POST['message']);
                //Check if the username or password boxes were not filled in
                if(!$name || !$email || !$contact || !$itemid){
                    //if not display an error message
                    echo "<center>Fields marked with <strong>&#40; &#42; &#421</strong> are mandatory!</center>";
                    }else{
                    //if the were continue checking
                        $result = mysql_query("INSERT INTO `wh_order` (`name`, `email`, `contact`, `itemid`, `itemquantity`, `ip`,`message`) VALUES('".$name."','".$email."','".$contact."','".$itemid."','".$itemquantity."','".$ip."','".$message."')");
                         //send the email with the order
                         if($result)
                            {
                                //send the email

                                $to = "ps@xyz.com";
                                $subject = "New order for Weaving Hope";

                                //headers and subject
                                $headers  = "MIME-Version: 1.0\r\n";
                                $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
                                $headers .= "From: ".$name." <".$email.">\r\n";

                                $body = "New contact<br />";
                                $body .= "Name: ".$name."<br />";
                                $body .= "Email: ".$email."<br />";
                                $body .= "Contact No.: ".$contact."<br />";
                                $body .= "Item Id: ".$itemid."<br />";
                                $body .= "Quantity: ".$itemquantity."<br />";
                                $body .= "Comment: ".$message."<br />";
                                $body .= "IP: ".$ip."<br />";

                                mail($to, $subject, $body, $headers);

                                //ok message

                                echo "Your message has been sent";
                            }
                        }
                    }
            ?>
4

1 に答える 1

3

ユーザー 'sifeiitd'@'localhost' のアクセスが拒否されました (パスワードを使用: NO)

私にはかなり明確なエラーのように見えます。mysql_connect()ステートメントを確認してくださいconnection.php

于 2012-06-08T10:47:04.710 に答える