Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

HELPP!!!!

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

HELPP!!!!

Postby ychan20 » Mon Feb 04, 2013 7:10 pm

Hi

Just new here anyone of you knows how to debug my error it is like this
Unknown column 'landline_show' in 'field list'

and here is my code on that


<?php
ob_start();
session_start();

include "includes/db_connect.php";

include("securimage.php");
$img = new Securimage();

$valid = $img->check($_POST['reg_verify']);
if($valid == true)
{
if(isset($_REQUEST['user_registration_submit']))
{

$reg_formtype=mysql_real_escape_string(trim($_REQUEST['reg_formtype']));

if($reg_formtype=='c')
{
$reg_usertype=2;
$reg_companyname=mysql_real_escape_string(trim($_REQUEST['reg_companyname']));
$reg_fax=mysql_real_escape_string(trim($_REQUEST['reg_fax']));
$reg_website=mysql_real_escape_string(trim($_REQUEST['reg_website']));
$reg_regon=mysql_real_escape_string(trim($_REQUEST['reg_regon']));
$reg_nip=mysql_real_escape_string(trim($_REQUEST['reg_nip']));
$reg_krs=mysql_real_escape_string(trim($_REQUEST['reg_krs']));

}
else
{
$reg_usertype=1;
$reg_companyname='';
$reg_fax='';
$reg_website='';

$birthday_month=mysql_real_escape_string(trim($_REQUEST['birthday_month']));
$birthday_day=mysql_real_escape_string(trim($_REQUEST['birthday_day']));
$birthday_year=mysql_real_escape_string(trim($_REQUEST['birthday_year']));

if($birthday_month>0 && $birthday_month<=9)
{
$mon = "0".$birthday_month;
}
else
{
$mon = $birthday_month;
}

if($birthday_day>0 && $birthday_day<=9)
{
$dat = "0".$birthday_day;
}
else
{
$dat = $birthday_day;
}

$dob=$dat."-".$mon."-".$birthday_year;
//$dob = $birthday_year."-".$mon."-".$dat;
}

$reg_userfirstname=mysql_real_escape_string(trim($_REQUEST['reg_userfirstname']));
$reg_userlastname=mysql_real_escape_string(trim($_REQUEST['reg_userlastname']));
$reg_gender=mysql_real_escape_string(trim($_REQUEST['gender']));
$reg_addr1=mysql_real_escape_string(trim($_REQUEST['reg_addr1']));
$reg_addr2=mysql_real_escape_string(trim($_REQUEST['reg_addr2']));
$reg_country=$_REQUEST['reg_country'];
$reg_state=mysql_real_escape_string(trim($_REQUEST['reg_state']));
$reg_city=mysql_real_escape_string(trim($_REQUEST['reg_city']));
$reg_pin=mysql_real_escape_string(trim($_REQUEST['reg_pin']));
//$reg_pin1=mysql_real_escape_string(trim($_REQUEST['reg_pin1']));
// $reg_pin2=mysql_real_escape_string(trim($_REQUEST['reg_pin2']));
$reg_phone1=mysql_real_escape_string(trim($_REQUEST['reg_phone1']));
$reg_phone2=mysql_real_escape_string(trim($_REQUEST['reg_phone2']));
$lshow=mysql_real_escape_string(trim($_REQUEST['lshow']));
$mshow=mysql_real_escape_string(trim($_REQUEST['mshow']));
$reg_mobile1=mysql_real_escape_string(trim($_REQUEST['reg_mobile1']));
$reg_mobile2=mysql_real_escape_string(trim($_REQUEST['reg_mobile2']));
$reg_username=mysql_real_escape_string(trim($_REQUEST['reg_username']));
$reg_userpassword=mysql_real_escape_string(trim($_REQUEST['reg_userpassword']));
$reg_usercpassword=mysql_real_escape_string(trim($_REQUEST['reg_usercpassword']));
$reg_useremail=mysql_real_escape_string(trim($_REQUEST['reg_useremail']));
$reg_userlearn=mysql_real_escape_string(trim($_REQUEST['reg_userlearn']));
$reg_usermessage=mysql_real_escape_string(htmlspecialchars_decode($_REQUEST['reg_usermessage']));
//$reg_usermessage=mysql_real_escape_string($_REQUEST['reg_usermessage']);
$reg_newsletter=mysql_real_escape_string(trim($_REQUEST['reg_newsletter']));
$reg_terms=mysql_real_escape_string(trim($_REQUEST['reg_terms']));

//$reg_pin=$reg_pin1.'-'.$reg_pin2;
if(($reg_phone1!='') &&($reg_phone2!=''))
{
$reg_phone='+'.$reg_phone1.'-'.$reg_phone2;
}
if(($reg_mobile1!='') &&($reg_mobile2!=''))
{
$reg_mobile='+'.$reg_mobile1.'-'.$reg_mobile2;
}

if($reg_terms == "")
{
$chk =0;
}
else
{
$chk=1;
}

if($reg_newsletter == "")
{
$nletter =0;
}
else
{
$nletter=1;
}


$ip=$_SERVER['REMOTE_ADDR'];
$status=0;
$dstatus=0;

//set the random id length
$random_id_length = 6;

//generate a random id encrypt it and store it in $rnd_id
$rnd_id = crypt(uniqid(rand(),1));

//to remove any slashes that might have come
$rnd_id = strip_tags(stripslashes($rnd_id));

//Removing any . or / and reversing the string
$rnd_id = str_replace(".","",$rnd_id);
$rnd_id = strrev(str_replace("/","",$rnd_id));

//finally I take the first 10 characters from the $rnd_id
$rnd_id = substr($rnd_id,0,$random_id_length);
$today = date("dmy");
#echo "Random Id: $today$rnd_id";
$random_req_id=("$today$rnd_id");



$str = "insert into userregister (username,email,password,usertype,firstname,lastname,gender,dob,address1,address2,country, state,city,postalcode,landline,mobile,companyname,fax,website,userlearn,message,terms,newsletter,status, delete_status,reg_date,reg_IP_address,randomkey,reg_regon,reg_nip,reg_krs,landline_show,mobile_show) values ('$reg_username','$reg_useremail','$reg_userpassword','$reg_usertype', '$reg_userfirstname','$reg_userlastname','$reg_gender','$dob','$reg_addr1','$reg_addr2','$reg_country','$reg_state', '$reg_city','$reg_pin','$reg_phone','$reg_mobile','$reg_companyname','$reg_fax','$reg_website','$reg_userlearn','$reg_usermessage','$chk','$nletter','$status','$dstatus',NOW(),'$ip','$random_req_id','$reg_regon','$reg_nip','$reg_krs','$lshow','$mshow')";




$ins=mysql_query($str) or die(mysql_error());
//echo $str; exit;
if($ins)
{
$get_id = mysql_fetch_array(mysql_query("select * from userregister where email='$reg_useremail'")) ;
$id = $get_id[0] ;
}

$fullpath = "http://$_SERVER[HTTP_HOST]".dirname($_SERVER[PHP_SELF]);

$to=$reg_useremail;

$subject="Please Activate your account";

$msg ="

<table width='500' cellpadding='0' cellspacing='0' border='0' style='border:solid 10px #F67628;'>

<tr bgcolor='#F67628' height='25'>

<td height='94'>

<img src='".$logo_url."' border='0px' />

</td>

</tr>

<tr bgcolor='#FFFFFF'> <td> <br> </td> </tr>

<tr bgcolor='#FFFFFF' height='30'>

<td height='27' valign='top' style='font-family:Arial; font-size:12px; line-height:18px; text-decoration:none; color:#000000; padding-left:20px;'>

Dear $reg_userfirstname,

</td>

</tr>

<tr bgcolor='#FFFFFF' height='35'>

<td height='24' style='padding-left:20px; font-family:Arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>

<b>Username</b> : $reg_username

</td>

</tr>

<tr bgcolor='#FFFFFF' height='35'>

<td height='23' style='padding-left:20px; font-family:Arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>

<b>Password</b> : $reg_userpassword

</td>

</tr>

<tr bgcolor='#FFFFFF' height='35'>

<td height='32' style='padding-left:20px; font-family:Arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000;'>

Click <a href='".$mail_url."/ActivateSeekers.php?usermail=".$reg_useremail."&activatekey=".$random_req_id."' target='_blank'> Here </a> To Activate Your Account.

<br><br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OR <br><br>

Copy and Paste the Below URL: ".$mail_url."/ActivateSeekers.php?usermail=".$reg_useremail."&activatekey=".$random_req_id."

</td>

</tr>

<tr bgcolor='#FFFFFF'>

<td height='77' align='left' style='padding-left:20px; font-family:Arial; font-size:11px; line-height:18px; text-decoration:none; color:#000000; padding-left:20px;'>

<p><b>Regards,</b><br> ".$siteteam." <br>

<a href='".$sitecom."' target='_blank'> ".$sitecom." </a>
</p>
</td>

</tr>

<tr bgcolor='#FFFFFF'><td> </td></tr>

<tr height='40' bgcolor='#F67628'>

<td align='right' style='font-family: Arial, Helvetica, sans-serif;font-size: 10px;background-color:#F67628;'>

<font color='white'> &copy; Copyright ".date('Y')." <b><i> ".$siteteam." </i></b>. </font>

</td>

</tr>

</table>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
//$headers .= 'To:'.$reg_userfirstname.'<'.$to.'>' . "\r\n";
$headers .= 'From:'.$siteadmin.'<'.$siteadmin.'>' . "\r\n";
$headers .= ""."\r\n";


//echo $headers; exit;

if(@mail($to,$subject,$msg,$headers))
{
//header("location:thanks.php?id=$id");
header("location:success.php?succs");
exit;
}
else
{
header("location:register.php?merr");
exit;
}



}
}
else if(($valid == false) && (isset ($_POST['reg_verify'])) )
{
//$reg_result =3;
header("location:register.php?verr");
exit;

}
?>



Thanks for your help! guys!
ychan20
New php-forum User
New php-forum User
 
Posts: 5
Joined: Mon Feb 04, 2013 4:44 pm

Re: HELPP!!!!

Postby simplypixie » Mon Feb 04, 2013 9:45 pm

Firstly, when posting code please put it in the Code container so it is easier to read (the button in between Quote and list).

With regard to your error, you have a field name called landline_show in your insert query which basically doesn't exist in your database table, so check the name of this field in your database.
User avatar
simplypixie
php-forum Active User
php-forum Active User
 
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire

Re: HELPP!!!!

Postby ychan20 » Tue Feb 05, 2013 8:13 pm

ok thanks got to check it......

what should i do?
ychan20
New php-forum User
New php-forum User
 
Posts: 5
Joined: Mon Feb 04, 2013 4:44 pm

Re: HELPP!!!!

Postby simplypixie » Tue Feb 05, 2013 10:32 pm

Sorry I don't understand your question, are you asking how to check your database?
User avatar
simplypixie
php-forum Active User
php-forum Active User
 
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire

Re: HELPP!!!!

Postby seandisanti » Thu Feb 07, 2013 12:20 pm

lol, you should look in the table that you're trying to insert into, and verify the field name, because the one you're trying to populate does not exist in that table. also on an unrelated note, you are typing the same thing over and over and over; that should be a warning signal that you are in need of some refactoring. writing a function string_prepare($value) or sp($value) even, to do your trimming and escaping would save you a lot of typing. here, i'll give you a freebie, just to save you some time and make your code more readable (and less repetitive).
Code: Select all
<?php
function sp($data=array()){
    if (! is_array($data)){
        return mysql_real_escape_string(trim($data));
    }
    foreach ($data as $evilInputThatWantsToCorruptMyDataSoIMustCleanIt_key=>$evilInputThatWantsToCorruptMyDataSoIMustCleanIt_value){
        $data[$evilInputThatWantsToCorruptMyDataSoIMustCleanIt_key]=mysql_real_escape_string(trim($evilInputThatWantsToCorruptMyDataSoIMustCleanIt_value));
    }
    return $data;
}


***edit*** fixed the spot where i apparently forgot how to speak english for a second.
Last edited by seandisanti on Thu Feb 07, 2013 12:24 pm, edited 1 time in total.
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 783
Joined: Mon Oct 01, 2012 12:32 pm

Re: HELPP!!!!

Postby seandisanti » Thu Feb 07, 2013 12:22 pm

Just in case it's not immediately obvious, that sp() can take a value as a string or an array. so if you wanted to send it your $_POST array (quit using request btw, it's a horrible idea for many reasons) it will go ahead and escape and trim all values therein for quick and easy use.
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 783
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron