0

This simple code isn't working, when I try, the error message comes:

Warning: mysql_result() expects parameter 1 to be resource

I tried a lotenter code here. Is there any function to call?

<?php require 'connection.php';

$query="SELECT id FROM log_reg WHERE username='raj' AND password='raj'"; 
$query_run=mysqli_query($con,$query);
echo $a=mysql_result($query_run,0,"id"); ?>'
Dharman
  • 26,923
  • 21
  • 73
  • 125
  • 1
    This question has already been asked a billion times on Stack Overflow. For example, see [here](http://stackoverflow.com/q/11423106/2675154). Next time, please use the [Search function](http://stackoverflow.com/search) first! – honk Jan 06 '15 at 08:34
  • possible duplicate of [Reference - What does this error mean in PHP?](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – deceze Jan 06 '15 at 08:50
  • Does this answer your question? [Can I mix MySQL APIs in PHP?](https://stackoverflow.com/questions/17498216/can-i-mix-mysql-apis-in-php) – Dharman Aug 17 '20 at 21:56

1 Answers1

-1

Try this. You were mixing mysql and mysqli. Follow any single approach for the execution. You can edit your code as below for mysql approach. If you want to use mysqli, follow this link.

<?php 
  require 'connection.php';
  $query="SELECT id FROM log_reg WHERE username='raj' AND password='raj'"; 
  $query_run=mysql_query($query); //replaced the function name here
  echo $a=mysql_result($query_run,0,"id"); 
?>
Prerak Sola
  • 8,971
  • 5
  • 34
  • 60
  • again there are two errors 1) Warning: mysql_query() expects parameter 1 to be string,object given 2)Warning: mysql_result() expects parameter 1 to be resource, null given – user2814620 Jan 06 '15 at 08:56
  • see the updated answer. `mysql_query()` does not require `connection object`. – Prerak Sola Jan 06 '15 at 09:23