0

hi everyone, i've got quite similar with displaying user's information.
i've 2 form(K8 Form and K9 Form). To displaying user's information in K8 Form, i used the method with the way you guys taught me. and then after the user fill up the K8 Form, the K8 Form information will be displaying on K9 Form. and that is the problem.I used the same way to show the information but the information about K8 Form doesn't show up in the K9 Form. in K8 Form, the primary key is "k8goodsID".
here are the way i did :

$_SESSION['k8goodsID']=$tenantIdentifier;

"
"
"

$query_k8goodsin = "SELECT * FROM k8_goodsin WHERE k8goodsID='".$_SESSION['k8goodsID']."'";
$rs_k8goodsin = mysql_query($query_k8goodsin) or die ('Query failed:' . mysql_error() . "<br /><\n $query_k8goodsin");
$reck8goodsin = mysql_num_rows($rs_k8goodsin);

"
"
"

<table id="tblStore" width="491" border="1" cellpadding="4px" cellspacing="0" bordercolor="#000000" >
<br />
<thead>
<th width="6%" class="labelcell">No</th>
<th width="25%" class="labelcell">Goods</th>
<th width="17%" class="labelcell">Quantity</th>
<th width="18%" class="labelcell">Price per Unit</th>
<th width="19%" class="labelcell">Total</th>
<th width="13%" class="labelcell"></th>
</thead>
<tr>
<td class="labelcell"><?php echo $count; ?></td>
<td><?php echo $reck8goodsin['goodsDesc']; ?></td>
<td><?php echo $reck8goodsin['k8goodsQty']; ?></td>
<td><?php echo $reck8goodsin['valuePerUnit']; ?></td>
<td><?php echo $reck8goodsin['valueTotal']; ?></td>
<td><input name="" type="checkbox" value="" /></td>
</tr>
</table>

and for the checkbox, i want the user's can pick the goods and displaying the goods picked and submit it.
can someone help me..

5
Contributors
18
Replies
100
Views
4 Years
Discussion Span
Last Post by masterjiraya
1

mysql_num_rows() function returns a number of found rows (an integer), not an array of rows. You should use a mysql_fetch_assoc() in a while loop function instead. Something like:

while(mysql_fetch_assoc($rs_k8goodsin)) {
    echo '<tr>';
    echo '<td class="labelcell">' . $count . '</td>';
    echo '<td>' . $reck8goodsin['goodsDesc'] . '</td>';
    echo '<td>' . $reck8goodsin['k8goodsQty'] . '</td>';
    echo '<td>' . $reck8goodsin['valuePerUnit'] . '</td>';
    echo '<td>' . $reck8goodsin['valueTotal'] . '</td>';

    echo '<td><input name="" type="checkbox" value="" /></td>';
    echo '</tr>';
}

And give the checkbox a sensible name.

Edited by broj1

0

but the data still not visible..is it because of the session id..?

0

but the data still not visible..is it because of the session id..?

Check out what the query returns. After this line:

$query_k8goodsin = "SELECT * FROM k8_goodsin WHERE k8goodsID='".$_SESSION['k8goodsID']."'";

put the following debug code:

die($query_k8goodsin);

It will display the query and stop the script. Now you can copy the displayed query into phpmyadmin and test it. You can also post it here.

0

i tried this query on phpmyadmin:

SELECT * FROM k8_goodsin WHERE k8goodsID='".$_SESSION['k8goodsID']."'

and it says

1064 - 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 'k8goodsID ']."'

LIMIT 0, 30' at line 1

Edited by sagisgirl

0

i tried this query on phpmyadmin:

SELECT * FROM k8_goodsin WHERE k8goodsID='".$_SESSION['k8goodsID']."'

You did not copy the code correctly. This is correct code (see my post above):

$query_k8goodsin = "SELECT * FROM k8_goodsin WHERE k8goodsID='".$_SESSION['k8goodsID']."'";

Or this is another variation of the same thing:

$query_k8goodsin = "SELECT * FROM k8_goodsin WHERE k8goodsID='{$_SESSION['k8goodsID']}'";

Edited by broj1

0

add a semicolon befre the last closing double quote

the reason I wan to put a semicolon on this part is to echo the string and try to copy the result and paste it to the phpmyadmin for query checking.

tell me what happens after you did this.
most probably $_session will be the culprit

Edited by masterjiraya

0

@broj1

    $query_k8goodsin = "SELECT * FROM k8_goodsin WHERE k8goodsID='".$_SESSION['k8goodsID']."'";

I have to copy this whole query into phpmyadmin.?
if yes, i still got the same error:
MySQL said: Documentation

1064 - 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 '$query_k8goodsin = "SELECT * FROM k8_goodsin WHERE k8goodsID='".$_SESSION['k8goo' at line 1

Edited by sagisgirl

0

no sagisgirl.you don't have to put this in phpmyadmin.
place this code in your php file as mysql doesn't recognises php variable and syntax.

Edited by IIM

0

@IIM

ok, i did put it in my php files.
but it wont show anything..

here how i do it :

$_SESSION['k8goodsID'] = $tenantIdentifier;

"
"

$query_k8goodsin = "SELECT * FROM k8_goodsin WHERE k8goodsID='".$_SESSION['k8goodsID']."'";
$rs_k8goodsin = mysql_query($query_k8goodsin) or die ('Query failed:' . mysql_error() . "<br /><\n $query_k8goodsin");
$reck8goodsin = mysql_fetch_array($rs_k8goodsin);

"
"

    while(mysql_fetch_assoc($rs_k8goodsin)) {
    echo '<tr>';
    echo '<td class="labelcell">' . $count . '</td>';
    echo '<td>' . $reck8goodsin['goodsDesc'] . '</td>';
    echo '<td>' . $reck8goodsin['k8goodsQty'] . '</td>';
    echo '<td>' . $reck8goodsin['valuePerUnit'] . '</td>';
    echo '<td>' . $reck8goodsin['valueTotal'] . '</td>';
    echo '<td><input name="k8Check" type="checkbox" value="" /></td>';
    echo '</tr>';
    }

Edited by sagisgirl

0

Sorry for being quiet so long, I was away.

The code with included debug statement should look like this:

$query_k8goodsin = "SELECT * FROM k8_goodsin WHERE k8goodsID='" . $_SESSION['k8goodsID'] . "'";

// DEBUG
die($query_k8goodsin);
// END DEBUG

$rs_k8goodsin = mysql_query($query_k8goodsin) or die ('Query failed:' . mysql_error() . "<br /><\n $query_k8goodsin");
$reck8goodsin = mysql_fetch_array($rs_k8goodsin);

while(mysql_fetch_assoc($rs_k8goodsin)) {
    echo '<tr>';
    echo '<td class="labelcell">' . $count . '</td>';
    echo '<td>' . $reck8goodsin['goodsDesc'] . '</td>';
    echo '<td>' . $reck8goodsin['k8goodsQty'] . '</td>';
    echo '<td>' . $reck8goodsin['valuePerUnit'] . '</td>';
    echo '<td>' . $reck8goodsin['valueTotal'] . '</td>';
    echo '<td><input name="k8Check" type="checkbox" value="" /></td>';
    echo '</tr>';
}

Thie code will display the query constructed with the value from session and stop the script. Paste the displayed query into phpadmin for testing or post it here.

0

@broj1,
its okay.
alright, i did put the debug in my php files, and it show like this:

SELECT * FROM k8_goodsin WHERE k8goodsID=''

so i try it on the phpmyadmin, it returned zero rows.
what does it mean..?

Edited by sagisgirl

0

@sagisgirl haven't I told you to echo the query variable first and check the output of the string in your browser and paste here the result of my suggestion.

here's the process, kindly add echo in your $query_k8goodsin

it will be like this

echo $query_k8goodsin = "SELECT * FROM k8_goodsin WHERE k8goodsID='" . $_SESSION['k8goodsID'] . "'";

this will show the result on what your $_SESSION['k8goodsID'] is handling.

the result on the browser will be

SELECT * FROM k8_goodsin WHERE k8goodsID=' (any value here of your $_SESSION['k8goodsID']) ';

0

SELECT * FROM k8_goodsin WHERE k8goodsID=''

so i try it on the phpmyadmin, it returned zero rows.
what does it mean..?

It means that the value for the $_SESSION['k8goodsID'] does not exist (there is nothing between single quotes). Where is the value for $_SESSION['k8goodsID'] supposed to be set? You have to look for error there. Do you have session_start() on the beginning of every script that uses session?

0

@broj1,
yes, i do have session_start() on the beginning every script.
so, how do i do for the value that is supposed to be set..?
im not sure how to do it..

0

OK, looking at your script again, here is where you set the value:

$_SESSION['k8goodsID']=$tenantIdentifier;

But if $tenantIdentifier has no value, $_SESSION['k8goodsID'] also has no value and the query fails. So you have to make sure $tenantIdentifier has appropriate value. Suppose it is an integer:

if(is_int($tenantIdentifier) && $tenantIdentifier > 0) {
    $_SESSION['k8goodsID']=$tenantIdentifier;
} else {
    die("ERROR: Tenant identifier has not been set!");
}

Basicaly, you have to make sure tenantIdentifier has been set to appropriate value before using it.

0

ok since we found the culprit, then I suppose at the start of the session is handling an empty variable. so you need to back track to the session start and retrieve your $tenantIdentifier is retrieving or containing something.

I guess that this $tenantIdentifier is accessing from Log-In or some sort of beginning transactions. kindly paste your code with that session variable

Edited by masterjiraya

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.