0

hi all,
in my insert project page wen i am above to insert project if the project size is greater than the allocated size then it should display some alert message,but my code not displaying anything.so please check my code.
Thank u.

<?php
$id=$_GET['f1'];
@session_start();
require_once ("check.php");
createsessions($username,$password,$userid,$projectid,$projectname,$filename,$size,$allocatedmemory,$answer,$usedmemory);
$con=mysql_connect("10.70.1.248","invensis","invensis");
if(!$con)
	{
		die('Could not connect: ' . mysql_error());
	}
mysql_select_db("database_myproject",$con);
if($_SESSION[usedmemory] < $_SESSION[allocatedmemory])
{
$sql="INSERT INTO projects(projectname,allocatedmemory,createdby)
VALUES ('$_POST[projectname]','$_POST[allocatedmemory] $_POST[size]','$_SESSION[username]')";
echo "New Project Added";
if(!mysql_query($sql,$con))
 {
 	die('Error:' . mysql_error());
 }
}                                          
else  
{
echo "cannot add project"; 
}
?>
2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by prem2
0

Hi nithis,
Just try the code ..

<?php
$id=$_GET['f1'];
@session_start();
require_once ("check.php");
createsessions($username,$password,$userid,$projectid,$projectname,$filename,$size,$allocatedmemory,$answer,$usedmemory);
$con=mysql_connect("10.70.1.248","invensis","invensis");
if(!$con)
	{
		die('Could not connect: ' . mysql_error());
	}
mysql_select_db("database_myproject",$con);
if($_SESSION[usedmemory] < $_SESSION[allocatedmemory])
{
$sql="INSERT INTO projects(projectname,allocatedmemory,createdby)
VALUES ('$_POST[projectname]','$_POST[allocatedmemory] $_POST[size]','$_SESSION[username]')";
echo "New Project Added";
if(!mysql_query($sql,$con))
 {
 	die('Error:' . mysql_error());
 }
}                                          
else  
{
echo "<script language='javascript'>
            alert('Cannot Add Project');
           </script>
";
}
?>

Try the above code i have included java script in u r code .check it out.

Thank you,
Prem

Edited by prem2: n/a

0

Hi,
In u r code

$_SESSION[usedmemory] < $_SESSION[allocatedmemory]

change it as

$_SESSION['usedmemory'] < $_SESSION['allocatedmemory']

and use echo to see u get all the values

echo $_SESSION['usedmemory'] ;
echo $_SESSION['allocatedmemory'];

thx u,
Prem

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.