0

Where is the problem plz:

?>

    <?php
      //get the total urls in the table
      include 'init.inc.php';
      function get_total_urls(){
         $total=mysql_query("SELECT COUNT ('url_key')FROM 'urls'");
          return (int)mysql_result($total,0);

      }

?>

message on the navigateur :

mysql_result(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\script short\shortener.inc.php on line 7

Rizier123
  • 57,440
  • 16
  • 89
  • 140
KIRA47
  • 1
  • 2
    Your query failed for some reason. Check `echo mysql_error();` to find out why. You must always check the return value of `mysql_query()` and not assume it succeeded. It may return `false`. – Michael Berkowski Dec 31 '14 at 14:00
  • You're using the wrong [**identifiers**](http://dev.mysql.com/doc/refman/5.0/en/identifier-qualifiers.html). – Funk Forty Niner Dec 31 '14 at 14:01
  • The manual is a good place to start. Also i hope the `?>` and `?>` at the top and bottom of you script aren't in your script actually. – Rizier123 Dec 31 '14 at 14:01
  • 2
    The columns/tables `url_key` and `urls` should not be single-quoted. – Michael Berkowski Dec 31 '14 at 14:01
  • See [When to use single quotes, double quotes, backticks](http://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks) to understand how strings and column/table identifiers should be quoted. – Michael Berkowski Dec 31 '14 at 14:03

1 Answers1

0

Try this:

?>

    <?php
      //get the total urls in the table
      include 'init.inc.php';
      function get_total_urls(){
         $total=mysql_query("SELECT COUNT ('url_key')FROM urls");
          return (int)mysql_result($total,0);

      }

?>

I think it's the single quotes around the table name url

DJ Burb
  • 2,263
  • 2
  • 28
  • 38