Jump to content

Archived

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

Solarpitch

mysqli_result() --> undefined?

Recommended Posts

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!

Share this post


Link to post
Share on other sites
check if you have the extension installed...

[code]<?phpinfo();?>[/code]

me!

Share this post


Link to post
Share on other sites
I just checked . . and it doesnt look like I have! What will I need to do to install it?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Open your PHP.INI, and find these...

[code];extension=php_mysql.dll
;extension=php_mysqli.dll[/code]

And then uncomment them...

[code]extension=php_mysql.dll
extension=php_mysqli.dll[/code]

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.com/forums/index.php/topic,110716.0.html


me!

Share this post


Link to post
Share on other sites
You can uncomment all you like but without the dll you get nothing. :)

Ray

Share this post


Link to post
Share on other sites
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.net/misc/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.net/misc/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.net/misc/phpini2.jpg

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

Ray

Share this post


Link to post
Share on other sites
check out this thread http://www.phpfreaks.com/forums/index.php/topic,95376.0.html

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

[code]<?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'];
?>[/code]
Ray

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Thanks again everyone for your help . . much appriciated!!  ;D

Ray taht code worked fine, I just have to make some modifications to it! 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.