rinteractive
-
Posts
27 -
Joined
-
Last visited
Never
Posts posted by rinteractive
-
-
Its giving error like this
Err You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 9
-
The above query is running but the table is not updating the record :'(
-
It give error on this line   //Connect to mysql server
as un excepted '&'
-
<?php
include_once ("functions.php");
include_once ("config.php");
//Start session
  //Connect to mysql server
  $link = mysql_connect("localhost","root","");
  if(!$link) {
      die('Failed to connect to server: ' . mysql_error());
  }
  //Select database
  $db = mysql_select_db("project");
  if(!$db) {
      die("Unable to select database");
  }
 
  //Array to store validation errors
  //Connect to mysql server
 
  //Sanitize the POST values
  $id = CleanVar(h_($_POST['id']));
  $fname = CleanVar(h_($_POST['fname']));
  $lname = CleanVar(h_($_POST['lname']));
  $gender = CleanVar(h_($_POST['gender']));
  $day= CleanVar(h_($_POST['day']));
  $month = CleanVar(h_($_POST['month']));
  $year = CleanVar(h_($_POST['year']));
  $country = CleanVar(h_($_POST['country']));
  $postalcode = CleanVar(h_($_POST['postalcode']));
  $error          =  "N";
//start the update
If($error == "N")
{
  $current_cat_sql = "UPDATE members SET firstname = '".d_($fname)."',
                              lastname = '".d_($lname)."',
                              gender= '".d_($gender)."',
                              day = '".d_($day)."',
                              month = '".d_($month)."',
                              year = '".d_($year)."',
                              country = '".d_($country)."',
                              postalcode = '".d_($postalcode)."'
                  WHERE member_id = '".d_($id)."'";
  mysql_query ($current_cat_sql) or die ("Err".mysql_error());
header("location: register-success.php");
      exit;
}
else
{
echo "error";
}
?>
This is the code i have used
-
i have tired your code it showing error message like this
Parse error: syntax error, unexpected '&' in C:\xampp\htdocs\project\admin\PHP-Login\register-edit-action1.php on line 6
-
when i write session_start(); code it given the error message like this
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\project\admin\PHP-Login\register-edit-action1.php:1) in C:\xampp\htdocs\project\admin\PHP-Login\register-edit-action1.php on line 6
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\project\admin\PHP-Login\register-edit-action1.php:1) in C:\xampp\htdocs\project\admin\PHP-Login\register-edit-action1.php on line 57
-
Thanks Adam
i have tired your then also it gives the same error message
-
hey guys ,
i have changed my code now bt error message is showing please anyone help me????
my code is this
<?php
include_once ("functions.php");
include_once ("config.php");
//Start session
//Connect to mysql server
$link = mysql_connect("localhost","root","");
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db("project");
if(!$db) {
die("Unable to select database");
}
//Array to store validation errors
//Connect to mysql server
//Sanitize the POST values
$id = CleanVar(h_($_POST['id']));
$fname = CleanVar(h_($_POST['fname']));
$lname = CleanVar(h_($_POST['lname']));
$gender = CleanVar(h_($_POST['gender']));
$day= CleanVar(h_($_POST['day']));
$month = CleanVar(h_($_POST['month']));
$year = CleanVar(h_($_POST['year']));
$country = CleanVar(h_($_POST['country']));
$postalcode = CleanVar(h_($_POST['postalcode']));
$error = "N";
if ($error == "Y"){
include_once ("register-edit.php");
exit;
}
else{
$current_cat_sql = "UPDATE members SET firstname = '".d_($fname)."',
lastname = '".d_($lname)."',
gender= '".d_($gender)."',
day = '".d_($day)."',
month = '".d_($month)."',
year = '".d_($year)."',
country = '".d_($country)."',
postalcode = '".d_($postalcode)."'
WHERE member_id = '".d_($id)."'";
mysql_query ($current_cat_sql) or die ("Err".mysql_error());
}
header("location: register-success.php");
exit;
?>
The error message is
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\project\admin\PHP-Login\register-edit-action1.php:1) in C:\xampp\htdocs\project\admin\PHP-Login\register-edit-action1.php on line 53
Thanks in Advance
-
hai guys!!!!
i am new to php and Mysql , i am trying to edit the user profile bt the table is not updating the records. The coding i have used for updating below:
<?php
include_once ("functions.php");
include_once ("config.php");
//Start session
session_start();
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Connect to mysql server
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
if(!get_magic_quotes_gpc()) {
$str = @trim(mysql_real_escape_string($str));
}
else {
return @trim($str);
}
}
//Sanitize the POST values
$fname = clean($_POST['fname']);
$lname = clean($_POST['lname']);
$gender = clean($_POST['gender']);
$day= clean($_POST['day']);
$month = clean($_POST['month']);
$year = clean($_POST['year']);
$country = clean($_POST['country']);
$postalcode = clean($_POST['postalcode']);
$id = Cleanvar($_REQUEST['id']);
//Input Validations
if($fname == '') {
$errmsg_arr[] = 'First name missing';
$errflag = true;
}
if($lname == '') {
$errmsg_arr[] = 'Last name missing';
$errflag = true;
}
if($gender == '') {
$errmsg_arr[] = 'Gender missing';
$errflag = true;
}
if($day == '') {
$errmsg_arr[] = 'Day missing';
$errflag = true;
}
if($month == '') {
$errmsg_arr[] = 'Month missing';
$errflag = true;
}
if($year == '') {
$errmsg_arr[] = 'Year missing';
$errflag = true;
}
if($country == '') {
$errmsg_arr[] = 'Country name missing';
$errflag = true;
}
if($postalcode == '') {
$errmsg_arr[] = 'Postal code missing';
$errflag = true;
}
//Check for duplicate login ID
//If there are input validations, redirect back to the registration form
//Create INSERT query
$qry = "UPDATE members SET firstname = '$fname' ,
lastname = '$lname',
gender = '$gender',
day = '$day',
month = '$month',
year = '$year',
country = '$country' ,
postalcode = '$postalcode'
WHERE member_id = '".d_($id)."'";
$result = mysql_query($qry);
//Check whether the query was successful or not
if($result) {
header("location: register-success.php");
exit();
}else {
die("Query failed".mysql_error());
}
?>
-
i am new to php , just i want the difference between session and cookies can any one explain me.
Thanks in Advance
-
Thanks Adam
my problem is solved now, your code helped me a lot
-
i am new to mysql, table is not creating even there is no error message. The code i have used below.
<?php
$con = mysql_connect("localhost","root","");
if(!$con)
{
echo"Connection failed".mysql_error();
}
mysql_select_db("project",$con);
$sql= "CREATE TABLE `experience` (
`id` int(11) unsigned NOT NULL auto_increment,
`years` int(11) NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM";
mysql_query($sql,$con);
mysql_close($con);
?>
Please any one help me
-
i am new to php and mysql. just i want to display the user id in all the pages when the user is login. i have created the session id for the user, i don't how to display the user id in all pages
please any one help me and give the suggestion
Thanks in Advance
-
Thanks wolfrat
my problem is solved. The image is displaying
Thanks a lot, your code is very helpful
-
Thanks wolfrat
i have used your coding but the image is not displaying
-
hey guys i am new to php ,
When i am retrieving the data from mysql table , the image is not displaying but it shows only the image name.
The coding i have used for retrieving is given just below:
<?php
include ("../include/config.php");
$sql = "SELECT id, name, photo FROM member";
$results = mysql_query($sql) or die ("Err, Problem with the database....".mysql_error());
$num=1;
while ($row = mysql_fetch_row($results)){
$id = $row[0];
$name = $row[1];
$photo = $row[2];
$display_str .= "
<tr bgcolor=\"#FFFFFF\">
<td align=\"center\">$num</td> <td align=\"center\"><input type=\"radio\" name=\"id\" value=\"$id\"></td>
<td align=\"center\">$name</td>
<td align=\"center\">$photo</td>
</tr>";
$num++;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Anti Corruption Intelligence Committee (ACIC) Admin Home</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="css/main.css" type="text/css" />
<script language="javascript" type="text/javascript">
<!--
function validate(action_type){
is_radio_checked=false;
if (document.head.id.length){
no_of_radio=document.head.id.length;
for (i=0;i < no_of_radio;i++){
if (document.head.id.checked == true){
is_radio_checked=true;
break;
}
}
}
else{
if (document.head.id.checked) is_radio_checked=true;;
}
if (is_radio_checked == false){
alert("Please Select the Type")
return false;
}
document.head.action_type.value = action_type;
if (action_type == "edit"){
document.head.submit();
return true;
}
if (action_type == "delete"){
delete_confirm = confirm("IMPORTANT: Are you sure you want to delete? ALL the products inside this Family will be DELETED.");
if(delete_confirm){
document.head.submit();
return true;
}
else{
return false;
}
}
return false;
}
-->
</script>
</head>
<body>
<strong><h2 align="center">Select a <u>Members</u> to edit</h2></strong>
<?php
if ($msg == '1'){
?>
<center><big><font color="green"><strong>Your Changes Have Been Saved !!!</strong></font></big></center>
<?php
}
if ($msg == '2'){
?>
<center><big><font color="green"><strong>Records Successfully Deleted !!!</strong></font></big></center>
<?php
}
?>
<form name="head" action="head-action.php" method="post">
<table width="50%" align="center" cellpadding="2" cellspacing="1" class="TableBG" border="2">
<tr bgcolor="#FFFFFF">
<th class="BlueBG"><strong>#</strong></th>
<th class="BlueBG"><strong>Select</strong></th>
<th class="BlueBG"><strong>member</strong></th>
<th class="BlueBG"><strong>Image</strong></th>
</tr>
<?php echo $display_str; ?>
<tr bgcolor="#FFFFFF">
<td align="center" colspan="5">
<input type="button" name="edit" value="Edit Member" class="FormButton" onclick=validate("edit")>
<input type="button" name="delete" value="Delete Member" class="FormButton" onclick=validate("delete")>
<input type="hidden" value="" name="action_type">
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="center" colspan="5" height="30"><a href="head-add.php"><b>Add Member</b></a></td>
</tr>
</table>
</form>
</body>
</html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
Please anybody help me
Thanks in advance
-
The table has been created already the only thing is to insert a data into table using php code.
The current code is below:
<?php
include_once ("../include/config.php");
include_once ("../include/functions.php");
$id = CleanVar(h_($_POST['id']));
$name = CleanVar(h_($_POST['name']));
$head = CleanVar(h_($_POST['head']));
$membership_no = CleanVar(h_($_POST['membership_no']));
$cat = CleanVar(h_($_POST['cat']));
$mobile = CleanVar(h_($_POST['mobile']));
$telephoner = CleanVar(h_($_POST['telephoner']));
$telephoneo = CleanVar(h_($_POST['telephoneo']));
$refcode = CleanVar(h_($_POST['refcode']));
$education = CleanVar(h_($_POST['education']));
$post = CleanVar(h_($_POST['post']));
$date_of_birth = CleanVar(h_($_POST['date_of_birth']));
$gender = CleanVar(h_($_POST['gender']));
$nationality = CleanVar(h_($_POST['nationality']));
$profession = CleanVar(h_($_POST['profession']));
$policestation = CleanVar(h_($_POST['policestation']));
$address1 = CleanVar(h_($_POST['address1']));
$address2 = CleanVar(h_($_POST['address2']));
$famillydetails1 = CleanVar(h_($_POST['familydetails1']));
$familydetails2 = CleanVar(h_($_POST['familydetails2']));
$municipalityoffice = CleanVar(h_($_POST['municipalityoffice']));
$place = CleanVar(h_($_POST['place']));
$detailsofbank = CleanVar(h_($_POST['detailsofbank']));
$date1 = CleanVar(h_($_POST['date1']));
$email = CleanVar(h_($_POST['email']));
$images = uploadImage('photo', GALLERY_IMG_DIR);
if ($images['image'] == '' ) {
echo "Error uploading file";
exit;
}
$image = $images['image'];
$sql = "INSERT INTO member (id,
membership_no,
cat,
head,
refcode,
post,
photo,
name,
date_of_birth,
Gender,
profession,
nationality,
education,
familydetails1,
familydetails2,
address1,
address2,
telephoner,
telephoneo,
mobile,
email,
policestation,
municipalityoffice,
detailsofbank,
date1,
place)
VALUES ($id,
$membership_no,
$cat,
$head,
$refcode,
$post,
$image,
$name,
$date_of_birth,
$gender,
$profession,
$nationality,
$education,
$familydetails1,
$familydetails2,
$address1,
$address2,
$telephoner,
$telephoneo,
$mobile,
$email,
$policestation,
$municipalityoffice,
$detailsofbank,
$date1,
$place)";
$result = mysql_query ($sql) or die (mysql_error());
header ("Location: member-list.php");
exit;
?>
It gives an error message
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' bvvbvbn, dfgfg, sdfggf, 24234, ' at line 40"
hey guys, please help me
-
hey guys,
Please help me
Thanks in Advance
-
hey guys!!
The table is already created only the problem is the data is not inserting in the table.
-
i have modified the code what your replied then also there is no error message and data is not inserted in the table
-
ya i have added after that code
$result = mysql_query ($sql) or die ("Err, Problem with the database....".mysql_error());
then also its not showing an error message and data is not inserting in the table
-
$sql = "INSERT INTO member(
membership_no,
cat,
head,
refcode,
post,
name,
date_of_birth,
Gender,
profession,
nationality,
education,
familydetails1,
familydetails2,
address1,
address2,
telephoner,
telephoneo,
mobile,
email,
policestation,
municipalityoffice,
detailsofbank,
date1,
place,
)
values (
'".d_($membership_no)."',
'".d_($cat)."',
'".d_($head)."',
'".d_($refcode)."',
'".d_($post)."',
'".d_($name)."',
'".d_($date_of_birth)."',
'".d_($gender)."'
'".d_($profession)."',
'".d_($nationality)."',
'".d_($education)."',
'".d_($familydetails1)."',
'".d_($familydetails2)."',
'".d_($address1)."',
'".d_($address2)."',
'".d_($telephoner)."',
'".d_($telephoneo)."',
'".d_($mobile)."',
'".d_($email)."',
'".d_($policestation)."',
'".d_($municipalityoffice)."',
'".d_($detailsofbank)."',
'".d_($date1)."',
'".d_($place)."'
)";
I have tried the above code there is no error message shown but the data is not inserting in the table
-
I want to insert data into mysql table using php
Below coding for creating table member
$sql="CREATE TABLE member
( id int(11) NOT NULL auto_increment,
membership_no varchar(100) ,
refcode varchar(100),
post varchar(100),
photo varchar(100),
cat int(11),
name varchar(100),
head int (11),
date_of_birth date,
Gender varchar(10),
profession varchar(50),
nationality varchar(30),
education varchar(30),
familydetails1 varchar(50),
familydetails2 varchar(50),
address1 varchar(100),
address2 varchar(100),
telephoner int ,
telephoneo int,
mobile int,
email varchar(80),
policestation varchar (70),
municipalityoffice varchar(100),
detailsofbank varchar(100),
date1 date,
place varchar(30),
PRIMARY KEY (id),
KEY `membership_no` (`membership_no`)
)";
The table is created. Here is the coding for inserting the insert data into table member but its giving error message “Err, Problem with the database....Column count doesn't match value count at row 1”
<?php
include_once ("../include/config.php");
include_once ("../include/functions.php");
$id = CleanVar(h_($_POST['id']));
$name = CleanVar(h_($_POST['name']));
$head = CleanVar(h_($_POST['head']));
$membership_no = CleanVar(h_($_POST['membership_no']));
$cat = CleanVar(h_($_POST['cat']));
$mobile = CleanVar(h_($_POST['mobile']));
$telephoner = CleanVar(h_($_POST['telephoner']));
$telephoneo = CleanVar(h_($_POST['telephoneo']));
$refcode = CleanVar(h_($_POST['refcode']));
$education = CleanVar(h_($_POST['education']));
$post = CleanVar(h_($_POST['post']));
$date_of_birth = CleanVar(h_($_POST['date_of_birth']));
$gender = CleanVar(h_($_POST['gender']));
$nationality = CleanVar(h_($_POST['nationality']));
$profession = CleanVar(h_($_POST['profession']));
$policestation = CleanVar(h_($_POST['policestation']));
$address1 = CleanVar(h_($_POST['address1']));
$address2 = CleanVar(h_($_POST['address2']));
$famillydetails1 = CleanVar(h_($_POST['familydetails1']));
$familydetails2 = CleanVar(h_($_POST['familydetails2']));
$municipalityoffice = CleanVar(h_($_POST['muncicipalityoffice']));
$place = CleanVar(h_($_POST['place']));
$detailsofbank = CleanVar(h_($_POST['detailsofbank']));
$date1 = CleanVar(h_($_POST['date1']));
$email = CleanVar(h_($_POST['email']));
$upload_path = "../images/"; // Folder where uploaded file will be stored
$allowed_ext = "image/pjpeg"; // Allowed file extension
$allowed_ext2 = "image/jpeg";
$allowed_ext3 = "image/gif";
$photo_name = $_FILES['photo_file']['name'];
$photo_temp = $_FILES['photo_file']['tmp_name'];
$photo_path = $site_path."images/".$photo_name;
$small_file_path = $site_path."prod_images/".$small_file_name;
$small_allowed_size = "10240"; // Max File size in bytes (10 KB)
$small_allowed_size_kb = number_format($small_allowed_size/1024,2); // Allowed File size in KB
$small_image_size = $_FILES['image_small_file']['size']; // Current File Size in bytes
$small_current_size = number_format($small_image_size/1024,2); // Current Size in KB
$small_width = "138";
$small_height = "134";
$error = "N";
if (!$name) $error_name = format_error ("Member Name cannot be left blank !!!");
if (!$mobile) $error_mobile = format_error ("Mobile number cannot be left blank !!!");
if (!$post) $error_name = format_error ("Post Name cannot be left blank !!!");
if (!$gender) $error_gender = format_error ("Gender cannot be left blank !!!");
if (!$profession) $error_profession = format_error ("Profession cannot be left blank !!!");
if (!$date_of_birth) $error_date_of_birth = format_error ("Date of Birth cannot be left blank !!!");
if (!$place) $error_name = format_error ("Place Name cannot be left blank !!!");
if (!$address1) $error_name = format_error ("Residence address cannot be left blank !!!");
if ($_FILES["image_small_file"]["error"] > 0) $error_image_small_file = format_error("Please specify Small Image");
$prod_sql = "SELECT id, membership_no from member WHERE upper(membership_no) = '".d_(strtoupper($membership_no))."'";
$prod_result = mysql_query ($prod_sql);
if (mysql_num_rows ($prod_result) > 0) $error_product_code = format_error ("Product Code already exists !!!");
if ($error == "Y"){
include_once ("member-add.php");
exit;
}
else{
// time to add the stuff...
$sql = "INSERT INTO member values (
null,
'".d_($membership_no)."',
'".d_($cat)."',
'".d_($head)."',
'".d_($refcode)."',
'".d_($post)."',
'',
'".d_($name)."',
'".d_($date_of_birth)."',
'".d_($gender)."'
'".d_($profession)."',
'".d_($nationality)."',
'".d_($education)."',
'".d_($familydetails1)."',
'".d_($familydetails2)."',
'".d_($address1)."',
'".d_($address2)."',
'".d_($telephoner)."',
'".d_($telephoneo)."',
'".d_($email)."',
'".d_($mobile)."',
'".d_($policestation)."',
'".d_($municipalityoffice)."',
'".d_($detailsofbank)."',
'".d_($date1)."',
'".d_($place)."'
)";
$result = mysql_query ($sql) or die ("Err, Problem with the database....".mysql_error());
$prod_id = mysql_insert_id();
if($photo_name && $photo_name != "none"){
// copy small image first
$explode_file_name = explode (".",$photo_name);
$small_image_name = $prod_id."-small";
$new_small_file_name = $photo_name.".".$explode_file_name[1];
move_uploaded_file($_FILES['image_small_file']['tmp_name'], $upload_path.$new_small_file_name);
// generate update string for small image
$update_small_image = "image_small = '".d_($new_small_file_name)."',";
}
$sql_update = "UPDATE member set
$update_small_image
WHERE id = '$prod_id'";
//echo $sql_update;
$result_update = mysql_query ($sql_update) or die ("Err, Problem with the database....".mysql_error());
header ("Location: member-list.php?cat=$cat&msg=1");
exit;
}
?>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php $con = mysql_connect("localhost","root",""); if(!$con) { echo"Connection failed".mysql_error(); } mysql_select_db("sample",$con); $sql="CREATE TABLE member ( id int(11) NOT NULL auto_increment, membership_no varchar(100) , refcode varchar(100), post varchar(100), photo varchar(100), cat int(11), name varchar(100), head int (11), date_of_birth date, Gender varchar(10), profession varchar(50), nationality varchar(30), education varchar(30), familydetails1 varchar(50), familydetails2 varchar(50), address1 varchar(100), address2 varchar(100), telephoner int (15), telephoneo int (15), mobile int (15), email varchar(80), policestation varchar (70), municipalityoffice varchar(100), detailsofbank varchar(100) /* forgot here to put camma (,) */ date1 date, place varchar(30), PRIMARY KEY (id), KEY `membership_no` (`membership_no`) )"; mysql_query($sql,$con) or die(mysql_error()); mysql_close($con); ?> </body> </html> Thanks you for replying me
Editing profile
in PHP Coding Help
Posted
please anybody help me????
i am running out of my time
my boss is scribbllinnng me