0

I have an error in a mysql connection. It says mysql_query() expects parameter 1 to be string on line 37

mysql_fetch_array() expects parameter 1 to be resource, null given in in folowing lines:

$result = mysql_query($link,"SELECT Name, id FROM skoleni WHERE Grupa = '".$_GET['grupa']."';");
while($row = mysql_fetch_array($result))
1
  • The $link is not required for mysql_query, this is if you are using mysqli Commented Feb 27, 2014 at 13:37

3 Answers 3

2
mysql_query("SELECT Name, id FROM skoleni WHERE Grupa = '".$_GET['grupa']."';");

No need of specifying connection parameter in mysql_query() function. For further reference see this https://www.php.net/manual/en/function.mysql-query.php

Sign up to request clarification or add additional context in comments.

Comments

0

The $link is not required. Try this:

`$result = mysql_query("SELECT Name, id FROM skoleni WHERE Grupa = '".$_GET['grupa']."';");

Comments

0

Important:

Stop using mysql_* api, its deprecated and generally bad. Use PDO or mysqli instead

Try

       $result = mysqli_query($link,"SELECT Name, id FROM skoleni WHERE Grupa = '".$_GET['grupa']."';");

       $rowcount=mysqli_num_rows($result);

     if ($rowcount > 0)
     {
         while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) 
         {
         }
     }

1 Comment

If you were going to post an example using mysqli, you could have at least used a prepared statement to avoid the obvious injection!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.