0

i am not getting the value in $sql2. so can anyone please....
thank u

$sql2="select allocatedmemory from projects where projectname='$projectassign'";
    mysql_error();
    $data1=mysql_query($sql2);
     echo '$data1';
2
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by cwarn23
0

Try this.

$sql2="select allocatedmemory from projects where projectname='$projectassign'";
    $data1=mysql_query($sql2) or die(mysql_error());
     echo '$data1';

[edit]
Oops, and the echo will need changing to suit your purposes. What are you trying to do on the echo line, trying to display allocatedmemory? If so then try the following

$sql2="select allocatedmemory from projects where projectname='$projectassign'";
$result=mysql_query($sql2) or die(mysql_error());
$data1=mysql_result($result,0);
echo $data1;

[/edit]

Edited by cwarn23: added info

0

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 6 in C:\Program Files\Apache Group\Apache2\htdocs\Project\upload.php on line 50
$data1

Yes I received your pm and the reason for that bug would be because the query returns zero results (no rows). So to solve this use the following:

$sql2="select allocatedmemory from projects where projectname='$projectassign'";
$result=mysql_query($sql2) or die(mysql_error());
if (mysql_num_rows($result)>0) {
$data1=mysql_result($result,0);
} else {
$data1='No data.';
}
echo $data1;
0

hey if i executed the same sql in mysql i am getting the value. but now it is displaying No Data.

0

Perhaps $projectassign isn't it's expected value.

i think the error might be here
$data1=mysql_result($d,0);

0

i think the error might be here
$data1=mysql_result($d,0);

Did you read my previous example fully as that code has a bug in it if your following my example. Not that that particular line would effect the if statement.

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.