2014-01-31 23:47
浏览 38


I have built a website have built a registration form. I have managed to get a connection with no errors, however the data isn't being entered from the form into the database. The code I have for the PHP is below...

$dbuser="        ";
$dbpass="        ";

$conn = mysql_connect($dbhost, $dbuser, $dbpass)
or die (mysql_error());


    if (isset($_POST['add'])){
        $firstname = $_POST['firstname'];
        $surname = $_POST['surname'];
        $dob = $_POST['dob'];
        $city = $_POST['city'];
        $r_country = $_POST['r_country'];
        $r_region = $_POST['r_region'];
        $r_level = $_POST['r_level'];
        $r_email = $_POST['r_email'];
        $r_contact_n = $_POST['r_contact_n'];
        $r_username = $_POST ['r_username'];
        $r_password =$_POST['r_password'];
        $membership_type =$_POST ['membership_type'];
            "INSERT INTO referees (firstname, surname, dob, city, r_country,  r_region, r_level, r_email, r_contact_n, r_username, r_password)
            VALUES    ('$firstname', '$surname', '$dob', '$city', '$r_county', '$r_region', '$r_level', '$r_email', '$r_contact_n', '$r_username', '$r_password')";
            mysql_query($insert) or die(mysql_error());

Any help on this matter would be appreciated! I can't seem to work out what the issue is myself having checked it numerous times!

图片转代码服务由CSDN问答提供 功能建议

我已经建立了一个已建立注册表格的网站。 我设法获得没有错误的连接,但是数据没有从表单输入到数据库中。 我对PHP的代码如下...

  $ dbhost =“refereelink.mysql”; 
 $ dbuser =“”; 
 $ dbpass =“”  ; 
 $ dbname =“refereelink_com”; 
 $ conn = mysql_connect($ dbhost,$ dbuser,$ dbpass)
ot die(mysql_error()); 
mysql_select_db($ dbname); 
 if(isset($ _ POST ['add'])){
 $ firstname = $ _POST ['firstname']; 
 $ surname = $ _POST ['surname']; 
 $ dob = $ _POST [  'dob']; 
 $ city = $ _POST ['city']; 
 $ r_country = $ _POST ['r_country']; 
 $ r_region = $ _POST ['r_region']; 
 $ r_level = $  _POST ['r_level']; 
 $ r_email = $ _POST ['r_email']; 
 $ r_contact_n = $ _POST ['r_contact_n']; 
 $ r_username = $ _POST ['r_username']; 
 $ r_password  = $ _ POST ['r_password']; 
 $ membership_type = $ _ POST ['membership_type']; 
 $ insert = 
“INSERT INTO裁判员(名字,姓氏,dob,城市,r_country,r_region,r_level,r_email,  r_contact_n,r_username,r_password)
 VALUES('$ firstname','  $ surname','$ dob','$ city','$ r_county','$ r_region','$ r_level','$ r_email','$ r_contact_n','$ r_username','$ r_password')“  ; 
 mysql_query($ insert)或die(mysql_error()); 

任何有关此事的帮助都将不胜感激! 我似乎无法弄清楚问题是我自己多次检查过这个问题!

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duandaoji3992 2014-02-11 22:41

    Solved the issue...

    I had included an extra field in the php code that wasn't in the database... school boy error really! Should of picked it up...

    Sjagr, reason for the host being as it is, is because its linked to the mysql from my domain host, so they set it to that and not local host unfortunately! It's a shame that my host doesn't allow access to local host with their service!

    打赏 评论
  • dongzhe6287 2014-01-31 23:50

    What is that? Use localhost or the address of the MySQL server

    You should also be wary of SQL injection and the fact that mysql_* is depreciated

    打赏 评论

相关推荐 更多相似问题