Jump to content

form


duncan_cowan

Recommended Posts

i have a html form and a php page that processes the form but when i run the process it comes up with this error:"Fatal error: Call to a member function on a non-object in /home/i04wasp/public_html/regformcheck.php on line 18"the process file contains:

<?php	// uncomment next line if running on PHP below 4.2.0$random = rand(1000000000, 9000000000); // between 0 and 100 inclusive	if (!$_POST['uname'] | !$_POST['passwd'] | !$_POST['passwd_again'] | !$_POST['email']) {		die('You did not fill in a required field.');	}	// check if username exists in database.	if (!get_magic_quotes_gpc()) {		$_POST['uname'] = addslashes($_POST['uname']);	}	$name_check = $db_object->query("SELECT username FROM users WHERE username = '".$_POST['uname']."'");	if (DB::isError($name_check)) {		die($name_check->getMessage());	}	$name_checkk = $name_check->numRows();	if ($name_checkk != 0) {		die('Sorry, the username: <strong>'.$_POST['uname'].'</strong> is already taken, please pick another one.');	}	// check passwords match	if ($_POST['passwd'] != $_POST['passwd_again']) {		die('Passwords did not match.');	}	// check e-mail format	if (!preg_match("/.*@.*..*/", $_POST['email']) | preg_match("/(<|>)/", $_POST['email'])) {		die('Invalid e-mail address.');	}	// no HTML tags in username, website, location, password	$_POST['uname'] = strip_tags($_POST['uname']);	$_POST['passwd'] = strip_tags($_POST['passwd']);	$_POST['website'] = strip_tags($_POST['website']);	$_POST['location'] = strip_tags($_POST['location']);	// check show_email data	if ($_POST['show_email'] != 0 & $_POST['show_email'] != 1) {		die('Nope');	}	/* the rest of the information is optional, the only thing we need to	check is if they submitted a website, 	and if so, check the format is ok. */	// now we can add them to the database.	// encrypt password	$_POST['passwd'] = md5($_POST['passwd']);	if (!get_magic_quotes_gpc()) {		$_POST['passwd'] = addslashes($_POST['passwd']);		$_POST['email'] = addslashes($_POST['email']);		$_POST['website'] = addslashes($_POST['website']);		$_POST['location'] = addslashes($_POST['location']);	}	$regdate = date('m d, Y');	$insert = "INSERT INTO users (			username, 			password, 			regdate, 			email,			location, 			show_email, 			last_login			act_num)			VALUES (			'".$_POST['uname']."',			'".$_POST['passwd']."', 			'$regdate', 			'".$_POST['email']."', 			'".$_POST['location']."', 			'".$_POST['show_email']."', 			'Never'			'$number')";	$add_member = $db_object->query($insert);	if (DB::isError($add_member)) {		die($add_member->getMessage());	}	$db_object->disconnect();?>

what is wrong???i have solved that problem by putting a database connection into it!! But now it says:"DB Error: syntax error"???

Link to comment
Share on other sites

Couldn't find the SQL syntax error?$insert = "INSERT INTO users ( username, password, regdate, email, location, show_email, last_login, act_num) VALUES ( '".$_POST['uname']."', '".$_POST['passwd']."', '$regdate', '".$_POST['email']."', '".$_POST['location']."', '".$_POST['show_email']."', 'Never', '$number')";

Link to comment
Share on other sites

I forgot to note that the database connect script is (the username and password have been replaced):

<?php//require the PEAR::DB classes.require_once 'DB.php';$db_engine = 'mysql';$db_user = 'i04wasp_duncan';$db_pass = '*********';$db_host = 'localhost';$db_name = '*******';$datasource = $db_engine.'://'.			  $db_user.':'.			  $db_pass.'@'.		 	  $db_host.'/'.				$db_name;$db_object = DB::connect($datasource, TRUE);/* assign database object in $db_object, if the connection fails $db_object will containthe error message. */// If $db_object contains an error:// error and exit.if(DB::isError($db_object)) {	die($db_object->getMessage());}$db_object->setFetchMode(DB_FETCHMODE_ASSOC);// we write this later on, ignore for now.include('check_login.php');?>

this script is now included at the top of the other file.

Link to comment
Share on other sites

im guessing that the line 18 is the line with DB::connect thing... what its saying is that DB is not a class that it is recognizing. if you defined DB in a different page, include it in the top of the file.

Link to comment
Share on other sites

Couldn't find the SQL syntax error?$insert = "INSERT INTO users ( username, password, regdate, email, location, show_email, last_login, act_num) VALUES ( '".$_POST['uname']."', '".$_POST['passwd']."', '$regdate', '".$_POST['email']."', '".$_POST['location']."', '".$_POST['show_email']."', 'Never', '$number')";
what do you mean??oh i see the comma!!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...