Jump to content

Archived

This topic is now archived and is closed to further replies.

Moron

So what's wrong here?

Recommended Posts

[quote]
$RESULTDS=mssql_query("SELECT DISTINCT LH.[Employee Number], LH.[Lmo], LH.[Lda], LH.[LYR], LH.[Hours], LH.[Leave Code], M2.[HRYRAT], M2.[EMPNO], M2.[MANLAP], M2.[MANLAC], M2.[MANLTC], M2.[MSKLAB], M2.[MSKLTC], M2.[MSKLAB], M2.[MSKLTC], M2.[NAMEMI], M2.[NAMEL], M2.[NAMEF] FROM LEAVHST LH INNER JOIN MASTERL2 M2 ON LH.[Employee Number]=M2.EMPNO WHERE M2.[EMPNO] = '".$_POST['employeenumber']."'  and LH.[LYR] >= '$last'  and LH.[Lda] >= '01' and LH.[Lmo] >= '07' ORDER BY LH.[LYR] desc, LH.[Lmo] desc, LH.[Lda] desc");
$RESULT=mssql_fetch_assoc($RESULTDS);


[b]$num_rows = mssql_num_rows($result['EMPNO']);
echo "$num_rows Rows\n";[/b]
[/quote]

The query works fine. The part I put in [b]bold[/b] gives this error:

[quote]
[b]Warning:[/b] mssql_num_rows(): supplied argument is not a valid MS SQL-result resource in [b]E:\User\Inetpub\wwwroot\PHPLeaveTime\leaveprocess.php[/b] on line [b]221[/b]
Rows[/quote]

Share this post


Link to post
Share on other sites
I guess $result['EMPNO'] holds an array. If it holds an array and you want to know how many items are in that array use count().

mssql_num_rows returns the number of rows returned from the SQL query.

Share this post


Link to post
Share on other sites
It doesn't work like that, you feed a query to mysql_num_rows not an array value or key like tihs

$select = "SELECT QUERY GOES HERE;";
$query = mysql_query($select);
$num = mysql_num_rows($query);
That would record the number of rows that were selected, it'll also work for update, and delete I believe to return the number that it acted upon.

Edit:

I replied at the same time you replied, that was cool.

Share this post


Link to post
Share on other sites
Dont double post! Use the modify button! I keep telling you that but you never listen.

Share this post


Link to post
Share on other sites
Sorry about that, I didn't see what you mean until now, THe only thing is when I am bumping If I modify it doesn't bump, but back to the problem, did you figure out what you needed, did it work this time?

Share this post


Link to post
Share on other sites
When something goes to the bottom, if you put the word, bump or anything it pops it back up to the first post.  Also we can't keep hijacking this post it has to get back on track.

Share this post


Link to post
Share on other sites
Changing this line...

[code]
$num_rows = mssql_num_rows($result['EMPNO']);
[/code]

...to this...

[code]
$num_rows = mssql_num_rows($RESULTDS);
[/code]

...should get you on the right track... ;)

Share this post


Link to post
Share on other sites
[quote author=HeyRay2 link=topic=105615.msg422006#msg422006 date=1156526391]
Changing this line...

[code]
$num_rows = mssql_num_rows($result['EMPNO']);
[/code]

...to this...

[code]
$num_rows = mssql_num_rows($RESULTDS);
[/code]

...should get you on the right track... ;)
[/quote]

Yep. It works.

Thanks!

:)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.