PROBLEMZZ!!!

0 Sid wadhwa · September 21, 2015
<?php
 require 'counter.inc.php';
 $user_ip = $_SERVER['REMOTE_ADDR'];
 
 function ip_exits ($ip){
  global $user_ip;
 
 }
 
 
 function update_count(){
  $query = "SELECT `count` FROM `hits_count`";
  if($query_run = mysql_query($query)){
   $count = mysql_result($query_run, 1 , 'count');
   echo $count;
  }
  
 }
 
 update_count();
?>





IN DATABASE : :
1 row and 1 field (field name=`count`)
value of count row 1 is '0'



//FOR MORE INFORMATION IT'S TUTORIAL NUMBER 124 - CREATING DATABASE HIT-COUNTER PART-2

Post a Reply

Replies

- page 1
Oldest  Newest  Rating
0 Ian Arbuckle · September 21, 2015
I assume you are watching Alex's tutorials and the code at that time is depreciated. I suggest checking out the updated series linked below.

https://www.youtube.com/watch?v=BEbKji_pSZM&list=PLfdtiltiRHWEbLm0ErHe7HgEOVIO26R_o
0 Sid wadhwa · September 22, 2015
why this code is depreciated ? any substitute of it ? n update series doesn't contain this !
0 Casper Hollemans · September 22, 2015
could you also post the error what your getting?
0 Sid wadhwa · September 22, 2015
( ! ) Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp\www\Teaching\hitCounter.php on line 14
Call Stack
#
Time
Memory
Function
Location
1
0.0049
134456
{main}( )
..\hitCounter.php:0
2
0.0055
134752
update_count( )
..\hitCounter.php:21
3
0.0055
134864
mysql_query ( )
..\hitCounter.php:14
0 Casper Hollemans · September 22, 2015
OH! haha I know that problem,
try to read the error really concentrated and you'll see that wamp doesn't support mysql instead it uses mysqli>
So for ex.
this:
$count = mysql_result($query_run, 1 , 'count');


becomes:
$count = mysqli_result($query_run, 1 , 'count');

That's all, it can be that mysqli does ask for some more paramethers.
The reason wamp does this is (what they think) that mysql an old thing is and shouldn't be used anymore :D
-Greets
0 Sid wadhwa · September 22, 2015
haha !! what the heck !! feeble mistake !
0 Sid wadhwa · September 22, 2015
anyways thankyou :)
0 Casper Hollemans · September 22, 2015
haha no problem, it spares you 2 hours watching to that lil error like me :p
0 Sid wadhwa · September 22, 2015
but yah from this you gained more actualization power !  n I gained what you know , nd u have invented a thing which is not known to you ! GR8 work man  :D !
0 Casper Hollemans · September 22, 2015
haha that's true, the 2 hours made it worth for me today and the next time you see a error I'm sure you'll look better at it and learn form it :D
  • 1
  • 2

PHP

107,084 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators