Jump to content


Photo

mysqli_result() --> undefined?


  • Please log in to reply
16 replies to this topic

#1 Solarpitch

Solarpitch
  • Members
  • PipPipPip
  • Advanced Member
  • 708 posts
  • LocationDublin, Ireland

Posted 19 October 2006 - 04:55 PM

Hey,

Does anyone know why I am getting an error saying that mysql_result() is undifined? I even try it as mysqli_result() and I still get the message.

$total_results = mysqli_query($mysql_connect, "SELECT COUNT(*) as Num FROM pages");
mysqli_result($total_results,0);

This code is a snippet from the pageination tutorial on the site that huggie pointed me too!
Welcome to 9AM Monday, the furthest point away from 5PM Friday.

#2 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 19 October 2006 - 05:06 PM

check if you have the extension installed...

<?phpinfo();?>

me!

#3 Solarpitch

Solarpitch
  • Members
  • PipPipPip
  • Advanced Member
  • 708 posts
  • LocationDublin, Ireland

Posted 19 October 2006 - 05:11 PM

I just checked . . and it doesnt look like I have! What will I need to do to install it?
Welcome to 9AM Monday, the furthest point away from 5PM Friday.

#4 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 19 October 2006 - 05:24 PM

OS type, (windows or Linux?)

me!

#5 Solarpitch

Solarpitch
  • Members
  • PipPipPip
  • Advanced Member
  • 708 posts
  • LocationDublin, Ireland

Posted 19 October 2006 - 05:29 PM

Windows XP!
Welcome to 9AM Monday, the furthest point away from 5PM Friday.

#6 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 19 October 2006 - 05:42 PM

Just go to php.net and download the zip file which contains a library of functions in the ext folder. Extract the contents to where you would keep you extentions then uncomment the dll in the php.ini file. Restart your web server.

The windows installer version does not contain the extra dll's

Ray

#7 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 19 October 2006 - 05:45 PM

Open your PHP.INI, and find these...

;extension=php_mysql.dll
;extension=php_mysqli.dll

And then uncomment them...

extension=php_mysql.dll
extension=php_mysqli.dll

Then restart IIS

Also have a look at this post, so PHP can find the dynamic dll(s) it needs to load the mysql and mysqli extensions!

bottom post!

http://www.phpfreaks...c,110716.0.html


me!


#8 Solarpitch

Solarpitch
  • Members
  • PipPipPip
  • Advanced Member
  • 708 posts
  • LocationDublin, Ireland

Posted 19 October 2006 - 05:47 PM

Cheers guys but I am nearly sure I already un-commented them.. ill check
Welcome to 9AM Monday, the furthest point away from 5PM Friday.

#9 Solarpitch

Solarpitch
  • Members
  • PipPipPip
  • Advanced Member
  • 708 posts
  • LocationDublin, Ireland

Posted 19 October 2006 - 05:51 PM

Yeah . . They are already un-commented! This is weird . . very strange
Welcome to 9AM Monday, the furthest point away from 5PM Friday.

#10 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 19 October 2006 - 05:51 PM

You can uncomment all you like but without the dll you get nothing. :)

Ray

#11 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 19 October 2006 - 06:06 PM

once you download the proper zip file for the version of php you are using open the zip files and extract the ext folder to your php directory. I didn't want to flood out the page so I made images links :)
http://www.theelders...sc/phpfiles.jpg

After you have the extension in the directory you want you have to edit the php.in  file
change the lines below. Make sure you put the paths in correctly
http://www.theelders...isc/phpini1.jpg

Also in the ini file add the extension for the mysqli.dll. mysql.dll is there just need to uncomment but mysqli.dll is not. I am not sure on all the different versions but mine was not there, I had to actually type it in
http://www.theelders...isc/phpini2.jpg

Once that is done restart your web server and should be all set

Ray

#12 Zane

Zane
  • Administrators
  • Advanced Member
  • 4,134 posts

Posted 19 October 2006 - 06:15 PM

check out this thread http://www.phpfreaks...ic,95376.0.html

btn_donate_SM.gif Want to thank me? Contribute to my PayPal piggy-bank
 

172938.png

#13 Solarpitch

Solarpitch
  • Members
  • PipPipPip
  • Advanced Member
  • 708 posts
  • LocationDublin, Ireland

Posted 19 October 2006 - 06:17 PM

.
Welcome to 9AM Monday, the furthest point away from 5PM Friday.

#14 Solarpitch

Solarpitch
  • Members
  • PipPipPip
  • Advanced Member
  • 708 posts
  • LocationDublin, Ireland

Posted 19 October 2006 - 06:21 PM

Ok . . I may have found the problem...

$total_results = mysqli_query($mysql_connect, "SELECT COUNT(*) as Num FROM pages");
echo $total_results;

mysql_result($total_results,0);

The echo displays "Object id #3" . . so I take it the incorrect value is being passed into the function! But why is it doing that?
Welcome to 9AM Monday, the furthest point away from 5PM Friday.

#15 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 19 October 2006 - 06:36 PM

Well you are echoing out the query which is and object so you will be getiing that. You need to echo out the RESULTS of the query. Also a good idea to seperate your query parts. you are also using 2 different functions either use mysql or mysqli not both.

<?php
$sql = "SELECT COUNT(*) as Num FROM pages";
  $res = mysqli_query($mysql_connect, $sql) or die (mysqli_error());
    $r=mysqli_fetch_assoc($res);
echo $r['Num'];
?>
Ray

#16 Solarpitch

Solarpitch
  • Members
  • PipPipPip
  • Advanced Member
  • 708 posts
  • LocationDublin, Ireland

Posted 19 October 2006 - 06:44 PM

Hi Ray, cheers for that...

I ran it and didnt get the error this time and the echo printed "102" which is the last value in the database. The script still isnt working but at least i am not getting that message!


Welcome to 9AM Monday, the furthest point away from 5PM Friday.

#17 Solarpitch

Solarpitch
  • Members
  • PipPipPip
  • Advanced Member
  • 708 posts
  • LocationDublin, Ireland

Posted 19 October 2006 - 06:48 PM

Thanks again everyone for your help . . much appriciated!!  ;D

Ray taht code worked fine, I just have to make some modifications to it! Thanks
Welcome to 9AM Monday, the furthest point away from 5PM Friday.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users