Jump to content

divinedesigns1

Recommended Posts

hey guys, yea im back trying to deal with the php language again, heeey you gotta give me credit for my determination lol anywho i keep on getting this error when i try to add another user to my database "im still in the process of learning", the error is Duplicate entry '0' for key 1 and in the script it says "else if ($email_check > 0){ $errorMsg = "<u>ERROR:</u><br />This Email is Taken..<br />"; }" which to my understanding if i want to add another email then it should become email/account number 1 "the script works, just having this problem with the duplication"

Link to comment
Share on other sites

since you're getting an SQL error, posting the query would be helpful too, as well as some background info on the table in question. It's most likely that you have an auto incrementing field and you are trying to set that ID within the query, as opposed to letting it increment on its own.

Link to comment
Share on other sites

ok this is my mysql scriptid int (11) not null primaryfirstname varchar (255) not nulllastname varchar (255) not nullcountry varchar (255) not nullstate varchar (255) not nullcity varchar (255) not nullzip varchar (255) not nullphone varchar (255) not nullemail varchar (255) not null uniquepass varchar (255) not nullsign_up_date date not null default '0000-00-00'last_log_date date not null defaul '0000-00-00'boi_body text nullweb varchar(255) nullyoutube varchar(255) nullaccount_type enum('a','b','c') not null default 'a'email_activate enum('0','1') not null default '0' thats the script for the mysql and this is the php

<?phpinclude_once("php/checkuserlog.php");?><?php$errorMsg = "";$firstname = "";$lastname = "";$country = "";$state = "";$city = "";$zip = "";$website = "";$youtube = "";$email = "";$email2 = "";$pass = "";$pass2 = "";// This code runs only if the form submit button is pressedif (isset ($_POST['firstname'])){	 $firstname = $_POST['firstname'];	 $lastname = $_POST['lastname'];	 $country = $_POST['country'];	 $state = $_POST['state'];	 $city = $_POST['city'];	 $zip = $_POST['zip'];	 $website = $_POST['website'];	 $youtube = $_POST['youtube'];	 $email = $_POST['email'];	 $email2 = $_POST['email2'];	 $pass = $_POST['pass'];	 $pass2 = $_POST['pass2'];	 $humancheck = $_POST['humancheck'];	 $firstname = stripslashes($firstname);	 $lastname = stripslashes($lastname);	 $state = stripslashes($state);	 $city = stripslashes($city);	 $zip = stripslashes($zip);	 $website = stripslashes($website);	 $youtube = stripslashes($youtube);	 $email = stripslashes($email);	 $pass = stripslashes($pass);	 $email2 = stripslashes($email2);	 $pass2 = stripslashes($pass2);	 $firstname = strip_tags($firstname);  $lastname = strip_tags($lastname);	 $state = strip_tags($state);	 $city = strip_tags($city);  $zip = strip_tags($zip);	 $website = strip_tags($website);	 $youtube = strip_tags($youtube);	 $email = strip_tags($email);	 $pass = strip_tags($pass);	 $email2 = strip_tags($email2);	 $pass2 = strip_tags($pass2);	 // Connect to database	 include_once "php/MyConnect.php";	 $emailCHecker = mysql_real_escape_string($email);  $emailCHecker = eregi_replace("`", "", $emailCHecker);	 // Database duplicate e-mail check setup for use below in the error handling if else conditionals	 $sql_email_check = mysql_query("SELECT email FROM myMembers WHERE email='$emailCHecker'");	 $email_check = mysql_num_rows($sql_email_check);	 // Error handling for missing data	 if ((!$firstname) || (!$lastname) || (!$country) || (!$state) || (!$city) || (!$zip) || (!$email) || (!$email2) || (!$pass) || (!$pass2)) {	 $errorMsg = '<font color=\"#990000">ERROR: You did not submit the following required information:</font><br /><br />'; 	 if(!$firstname){	   $errorMsg .= ' * First Name<br />';	 }  if(!$lastname){	   $errorMsg .= ' * Last Name<br />';	 }	 if(!$country){	   $errorMsg .= ' * Country<br />';	 }   if(!$state){	   $errorMsg .= ' * State or Provice<br />';	 	 }  if(!$city){	   $errorMsg .= ' * City<br />';	   	 }  if(!$zip){	   $errorMsg .= ' * Postal or Zip Code<br />';	   	 }    if(!$email){	   $errorMsg .= ' * Email Address<br />';	 	 }  if(!$email2){	   $errorMsg .= ' * Confirm Email Address<br />';	   	 }   if(!$pass){	   $errorMsg .= ' * Login Password<br />';	 	 }  if(!$pass2){	   $errorMsg .= ' * Confirm Login Password<br />';	   	 } 	 } else if ($email != $email2) {			  $errorMsg = 'ERROR: Your Email fields below do not match<br />';	 } else if ($pass != $pass2) {			  $errorMsg = 'ERROR: Your Password fields below do not match<br />';	 } else if ($humancheck != "") {			  $errorMsg = 'ERROR: Ahhhhh Alien!!!!, Kindly Clear The Field If You Are A Human<br />';  	 } else if ($email_check > 0){			  $errorMsg = "<u>ERROR:</u><br />This Email is Taken..<br />";   	 } else { // Error handling is ended, process the data and add member to database	 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  $firstname = mysql_real_escape_string($firstname);  $lastname = mysql_real_escape_string($lastname);	 $state = mysql_real_escape_string($state);	 $city = mysql_real_escape_string($city);  $zip = mysql_real_escape_string($zip);	 $website = mysql_real_escape_string($website);  $youtube = mysql_real_escape_string($youtube);	 $email = mysql_real_escape_string($email);	 $pass = mysql_real_escape_string($pass);   $firstname = eregi_replace("`", "", $firstname);  $lastname = eregi_replace("`", "", $lastname);  $state = eregi_replace("`", "", $state);  $city = eregi_replace("`", "", $city);  $zip = eregi_replace("`", "", $zip);  $website = eregi_replace("`", "", $website);  $youtube = eregi_replace("`", "", $youtube);  $email = eregi_replace("`", "", $email);  $pass = eregi_replace("`", "", $pass);	 $website = eregi_replace("http://", "", $website);  $youtube = eregi_replace("http://www.youtube.com/user/", "", $youtube); 	 // Add MD5 Hash to the password variable	 $db_password = md5($pass);	 // Add user info into the database table for the main site table(audiopeeps.com)	 $sql = mysql_query("INSERT INTO myMembers (firstname, lastname, country, state, city, zip, email, password, sign_up_date, website, youtube)	 VALUES('$firstname','$lastname','$country','$state','$city','$zip','$email','$db_password', now(),'$website','$youtube')") 	 or die (mysql_error());	 $id = mysql_insert_id();   // Create directory(folder) to hold each user's files(pics, MP3s, etc.) 	 mkdir("members/$id", 0755);    //!!!!!!!!!!!!!!!!!!!!!!!!!    Email User the activation link    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    $to = "$email";		      $from = "dwayne@divinedesigns1.net";    $subject = "Registration at Major";    //Begin HTML Email Message    $message = "Hi $firstname,   Complete this step to activate your login identity at Major.   Click the line below to activate when ready.   http://www.divinedesigns1.us/activation.php?id=$id&sequence=$db_password   If the URL above is not an active link, please copy and paste it into your browser address bar   Login after successful activation using your:    E-mail Address: $email   Password: $pass   See you on the site!   ";   //end of message$headers  = "From: $from\r\n";    $headers .= "Content-type: text\r\n";    mail($to, $subject, $message, $headers);   $msgToUser = "<h2>One Last Step - Activate through Email</h2><h4>OK $firstname, one last step to verify your email identity:</h4><br />   In a moment you will be sent an Activation link to your email address.<br /><br />   <br />   <strong><font color=\"#900\">VERY IMPORTANT:</font></strong>   If you check your email with your host providers default email application, there may be issues with seeing the email contents.  If this happens to you and you cannot read the message to activate, download the file and open using a text editor.<br /><br />   ";   include_once 'msgToUser.php';   exit();   } // Close else after duplication checks} else { // if the form is not posted with variables, place default empty variables     $errorMsg = "Fields marked with an [ * ] are required";	  $firstname = "";   $lastname = "";   $country = "";   $state = "";   $city = "";   $zip = "";   $website = "";   $youtube = "";   $email = "";   $email2 = "";   $pass = "";   $pass2 = "";}?>

Link to comment
Share on other sites

@birbal everything works, just the duplication error im getting #foxy yea i didnt had the auto_increment, ill go change that and see sup

Link to comment
Share on other sites

:blush: It works, its just the auto_increment that was out of place :) thank you for the new knowledge
Link to comment
Share on other sites

Without the auto_increment, and you not manually setting the ID, the Id takes the default value 0. If a record with 0 already exists, attempting to make a new one fails because the column is a primary key and must be unique.

Link to comment
Share on other sites

Without the auto_increment, and you not manually setting the ID, the Id takes the default value 0. If a record with 0 already exists, attempting to make a new one fails because the column is a primary key and must be unique.
oh alrite, now i know that, i got another error that doesnt seem to be matching anything i have in my scripts, the error said "Notice:Undefined variable: LogOptions in /home/content/14............./dds1us/top.php on line 12" but when i check it, it doesnt say anything, the same file "top.php" works on the index page www.divinedesigns1.us without the error
Link to comment
Share on other sites

Undefined means that you're trying to use a variable that doesn't have a value. If it works on the index page that means that something of the index page is giving it a set value.

Link to comment
Share on other sites

Undefined means that you're trying to use a variable that doesn't have a value. If it works on the index page that means that something of the index page is giving it a set value.
alright ill check it out, thanks again fox
Link to comment
Share on other sites

Undefined means that you're trying to use a variable that doesn't have a value. If it works on the index page that means that something of the index page is giving it a set value.
Ok, i got the last error it didnt fix, so im skipping that one for now because its not really messing up anything but this one is on the login page, i had about 6 of them and i figured out 3 but the other 3 im not getting the errors are as followed:Warning: Cannot modify header information - headers already sent by (output started at /home/content/14/8709614/html/dds1us/php/MyConnect.php:11) in /home/content/14/8709614/html/dds1us/login.php on line 70 The other 2 have to do with the cookies, because when i set the "remember me" it displays the error Warning:connot modify header information - headers already sent by (output started at /home/content/14/............./html/ddus1/hph/myconnect.php:11) in /home.contect/14/.............../html/dds1us/login.php on line 66 and 67 lol feel like giving up but dont wanna its a challenge and a half for me, lol anyway this is the script im using
<?php// Start Session to enable creating the session variables below when they log insession_start();// Force script errors and warnings to show on page in case php.ini file is set to not display themerror_reporting(E_ALL);ini_set('display_errors', '1');//-----------------------------------------------------------------------------------------------------------------------------------// Initialize some vars$errorMsg = '';$email = '';$pass = '';$remember = '';if (isset($_POST['email'])) {$email = $_POST['email'];$pass = $_POST['pass'];if (isset($_POST['remember'])) {  $remember = $_POST['remember'];}$email = stripslashes($email);$pass = stripslashes($pass);$email = strip_tags($email);$pass = strip_tags($pass);// error handling conditional checks go hereif ((!$email) || (!$pass)) {  $errorMsg = 'Please fill in both fields';} else { // Error handling is complete so process the info if no errors  include 'php/MyConnect.php'; // Connect to the database  $email = mysql_real_escape_string($email); // After we connect, we secure the string before adding to query	 //$pass = mysql_real_escape_string($pass); // After we connect, we secure the string before adding to query  $pass = md5($pass); // Add MD5 Hash to the password variable they supplied after filtering it  // Make the SQL query	    $sql = mysql_query("SELECT * FROM myMembers WHERE email='$email' AND password='$pass' AND email_activated='1'");  $login_check = mysql_num_rows($sql);	    // If login check number is greater than 0 (meaning they do exist and are activated)  if($login_check > 0){	   while($row = mysql_fetch_array($sql)){		 // Pleae note: Adam removed all of the session_register() functions cuz they were deprecated and	 // he made the scripts to where they operate universally the same on all modern PHP versions(PHP 4.0  thru 5.3+)	 // Create session var for their raw id	 $id = $row["id"];  	 $_SESSION['id'] = $id;	 // Create the idx session var	 $_SESSION['idx'] = base64_encode("g4p3h9xfn8sq03hs2234$id");				    // Create session var for their username	 $username = $row["username"];	 $_SESSION['username'] = $username;	 // Create session var for their email	 $useremail = $row["email"];	 $_SESSION['useremail'] = $useremail;	 // Create session var for their password	 $userpass = $row["password"];	 $_SESSION['userpass'] = $userpass;	 mysql_query("UPDATE myMembers SET last_log_date=now() WHERE id='$id' LIMIT 1");	   	   } // close while	   // Remember Me Section	   if($remember == "yes"){				    $encryptedID = base64_encode("g4enm2c0c4y3dn3727553$id");		   setcookie("idCookie", $encryptedID, time()+60*60*24*100, "/"); // Cookie set to expire in about 30 days		   setcookie("passCookie", $pass, time()+60*60*24*100, "/"); // Cookie set to expire in about 30 days	   }	   // All good they are logged in, send them to homepage then exit script	   header("location: index.php");	   exit();  } else { // Run this code if they do not exist	  $errorMsg = "no No NO!!! Try Again!!<br /> Email or Password Is Incorrect!!!";  }    } // Close else after error checks} //Close if (isset ($_POST['uname'])){?>

Link to comment
Share on other sites

if there is any output ahs been made already to browser it cant send header again cause headers are being sent with the first output on the browser. Did you fixed the previous undefined error notice? even it can also send the headers and be reason of the warning, just make sure first there is no any output.

Link to comment
Share on other sites

if there is any output ahs been made already to browser it cant send header again cause headers are being sent with the first output on the browser. Did you fixed the previous undefined error notice? even it can also send the headers and be reason of the warning, just make sure first there is no any output.
alright ill check it out, thank for the knowledge guys really appreciate the help
Link to comment
Share on other sites

Is there another way to redirect a page in php besides using "header("location: index.php");" ?

Link to comment
Share on other sites

there is another option header('refresh=5;url='http:/somesite.com'); where refresh determine the delay of the redirect.there is a backdraw if browser has redirect disabled it will not be redirected something like metra redirect. location heeader will be more ppropiate here.what about your errors? is those resolved?

Link to comment
Share on other sites

make sure there is absolutely no white space before the openeing php tag, and make sure you are saving your files as UTF-8 NO BOM.

Link to comment
Share on other sites

2 of the errors have to do with the cookies, which im working on atm and the other error is the header output which im working on also, soon as i fix all of them im going to redo the site

Link to comment
Share on other sites

make sure there is absolutely no white space before the openeing php tag, and make sure you are saving your files as UTF-8 NO BOM.
alrite ill double check to make sure theres no white space
Link to comment
Share on other sites

is there another way to say "while($row = mysql_fetch_array($sql_blabs))" because its bring up an error, saying it isnt a supported agruement

Link to comment
Share on other sites

it is not problem with while loop. you did not specify the error. you should tell us the error so that we could solve that. it seems like $sql_blabs is probably is getting false thats why it is saying invalid arguments.

Link to comment
Share on other sites

it is not problem with while loop. you did not specify the error. you should tell us the error so that we could solve that. it seems like $sql_blabs is probably is getting false thats why it is saying invalid arguments.
so how do i fine this......AHHHHH i really need to learn how to fix php errors lol.....but how can i fix this problem?
Link to comment
Share on other sites

it is happening probably for your query is failing so that mysql_query() is returning false, if that is the error is saying. you can track why your query is failing,using mysql_error()

Link to comment
Share on other sites

it is happening probably for your query is failing so that mysql_query() is returning false, if that is the error is saying. you can track why your query is failing,using mysql_error()
that is so true, my mysql keep dropping for the pass few days, i was going to contact the company that host my stuff, but didnt bother, thanks man
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...