如何获得注册表格 [英] How do I get a register form working

查看:66
本文介绍了如何获得注册表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi, 

So I have a register form in which I keep receiving this error for: 
Fatal error: Uncaught Error: Using $this when not in object context in /homepages/33/d706589573/htdocs/Project/dbConnect.php:10 Stack trace: #0 /homepages/33/d706589573/htdocs/Project/help.php(35): include() #1 {main} thrown in /homepages/33/d706589573/htdocs/Project/dbConnect.php on line 10

This is the code from my db.connect file: 
<?php


try {
	$conn = new PDO("mysql:host=$host_name;db name=$database",$user_name,$password);
	//set the PDO error mode to exception 
	$conn->setAttrribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
	echo "connection to MYSQL sever successfully established!";
}
catch(PDOException $e)
{
	echo"Connection failed: ".$e->getMessage();
}

The line which Is bold is the line I am getting an error on, has anyone any idea how I can fix this error? 





我的尝试:



我已经尝试了替代代码,但仍未解决问题



What I have tried:

I have tried alternative code but still havent suessed the problem

推荐答案

这不在/homepages/33/d706589573/htdocs/Project/dbConnect.php中的对象上下文中:10堆栈跟踪:#0 /homepages/33/d706589573/htdocs/Project/help.php(35):include()#1 {main}引入/homepages/33/d706589573/htdocs/Project/dbConnect.php on第10行

这是我的db.connect文件中的代码:
<?php


try {
this when not in object context in /homepages/33/d706589573/htdocs/Project/dbConnect.php:10 Stack trace: #0 /homepages/33/d706589573/htdocs/Project/help.php(35): include() #1 {main} thrown in /homepages/33/d706589573/htdocs/Project/dbConnect.php on line 10 This is the code from my db.connect file: <?php try {


conn = new PDO(mysql:host =
conn = new PDO("mysql:host=


host_name; db name =
host_name;db name=


这篇关于如何获得注册表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆