Profile updation in php

hi guys need some help its just a small miss out im sensing i have an update profile code for users and its working fine im applying the same code for different user like for NGO users profile but it just echoin NO column found even thou i have the table for ngo users ;(---------->)look for this arrow please help

<?php
include 'session.php';
if(!isset($_SESSION['login_user']))
{
	header("location:login.php");
}

$user_check = $_SESSION['login_user'];

$update1=$_POST['fname'];
$update2=$_POST['ngo'];
$update3=$_POST['email'];
$update4=$_POST['address'];
$link=mysqli_connect("localhost","root","","sysp");
if($link===false)
{
 die("error cant connect".mysqli_connect_error());
}
if (isset($_POST['submit'])) 
{
$update1=$_POST['fname'];
$update2=$_POST['ngo'];
$update3=$_POST['email'];
$update4=$_POST['address'];
}
		$query="SELECT fname,ngo,email,address, FROM ngo WHERE email='$user_check' ";
		$result=mysqli_query($link,$query);
		if(!$result)
{
	echo"no column found";---------->Main problem
}
else{
	//----------------------------First Name update--------------------------------//
	if($_POST['fname']==$update1)
	{
$sql="UPDATE ngo SET  fname='$update1' WHERE email='$user_check' ";
			$res = mysqli_query($link, $sql); // ** actually run the query
			if ($res){ echo"Updated successfully";
} else {
echo"Didnt update ";
}
	}
//--------------------------------------end---------------------------------------------------//
	
	//----------------------------NGO name update--------------------------------//
	if($_POST['ngo']==$update2)
	{
$sql="UPDATE ngo SET  ngo='$update2' WHERE email='$user_check' ";
			$res = mysqli_query($link, $sql); // ** actually run the query
			if ($res){ echo"Updated successfully";
} else {
echo"Didnt update ";
}
	}
		//--------------------------------------end---------------------------------------------------//
	
	//----------------------------Email update--------------------------------//
if($_POST['email']==$update3)
	{
$sql="UPDATE ngo SET  email='$update3' WHERE email='$user_check' ";
			$res = mysqli_query($link, $sql); // ** actually run the query
			if ($res){ echo"Updated successfully";
} else {
echo"Didnt update ";
}
	}
	//--------------------------------------end---------------------------------------------------//
	
	//----------------------------ADDRESS update--------------------------------//
if($_POST['address']==$update4)
	{
$sql="UPDATE ngo SET  address='$update4' WHERE email='$user_check' ";
			$res = mysqli_query($link, $sql); // ** actually run the query
			if ($res){ echo"Updated successfully";
} else {
echo"Didnt update ";
}
}
}	
	//--------------------------------------end---------------------------------------------------//
mysqli_close($link);
?>

Try echoing out the $query statement and $link values.

Also if you are using PhpMyAdmin paste the $query value into the tables’s SQL

echo '<pre>'; // pretty formatting start
   $query="SELECT fname,ngo,email,address, FROM ngo WHERE email='$user_check' ";
   $result=mysqli_query($link,$query);
   print_r( $query );
   print_r( $link );
echo '</pre>'; // pretty formatting finish
die; 


i got it man a small semi colon(,) was there in select query damn anyway thanks for ur time to reply :slight_smile:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.