Jump to content


Photo

So what's wrong here?


  • Please log in to reply
9 replies to this topic

#1 Moron

Moron
  • Members
  • PipPipPip
  • Advanced Member
  • 368 posts

Posted 25 August 2006 - 03:48 PM

$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);


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


The query works fine. The part I put in bold gives this error:

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



#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 25 August 2006 - 03:55 PM

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.

#3 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 25 August 2006 - 03:55 PM

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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 25 August 2006 - 03:57 PM

Dont double post! Use the modify button! I keep telling you that but you never listen.

#5 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 25 August 2006 - 04:01 PM

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?

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#6 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 25 August 2006 - 04:06 PM

What's 'bumping' guys?

Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#7 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 25 August 2006 - 04:12 PM

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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#8 HeyRay2

HeyRay2
  • Members
  • PipPipPip
  • Advanced Member
  • 223 posts

Posted 25 August 2006 - 05:19 PM

Changing this line...

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

...to this...

$num_rows = mssql_num_rows($RESULTDS);

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

#9 Moron

Moron
  • Members
  • PipPipPip
  • Advanced Member
  • 368 posts

Posted 25 August 2006 - 07:57 PM

Changing this line...

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

...to this...

$num_rows = mssql_num_rows($RESULTDS);

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


Yep. It works.

Thanks!

:)

#10 HeyRay2

HeyRay2
  • Members
  • PipPipPip
  • Advanced Member
  • 223 posts

Posted 25 August 2006 - 08:40 PM

Glad to help!  ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users