Jump to content

mysql_fetch_assoc() ?


managerstats

Recommended Posts

<ol>
<?php
include '../globals.php';

$manager = $_GET['manager'];  
$query = "SELECT 'manager' FROM 'tablename' WHERE manager='.$manager.' ";
$rs = mysql_query($query); 
while ($row = mysql_fetch_assoc($rs)) 

{
echo '<li>' . $row['manager'] . '</strong> '; 
echo '<strong>' . $row['won'] . '</strong> '; 
echo '<strong>' . $row['drawn'] . '</strong> '; 
echo '<strong>' . $row['lost'] . '</strong> '; 
echo '<strong>' . $row['total'] . '</strong> '; 
echo '<strong>' . $row['club'] . '</strong></li> '; 
} 

mysql_close(); ?>
</ol>

I have been around in circles trying to solve this without success.

 

Essentially I am trying to set up anchors such as;

<a href="sitename.com/?manager=Micky Adams">Micky Adams</a>

But I get;

 

  Quote
PHP Warning:  mysql_fetch_assoc() expects parameter 1 to be resource

 

Can someone please point me in the right direction or let me know where I have gone wrong in my code?

Link to comment
https://forums.phpfreaks.com/topic/277878-mysql_fetch_assoc/
Share on other sites

the syntax you are using for the $manager variable in the WHERE clause is adding dots . before and after the value, so your WHERE clause is false and is not matching anything.

 

you can put a php variable inside of a double quoted string. you also had single quotes around the column name in the SELECT clause, which would have literally returned the string 'manager' -

$query = "SELECT manager FROM tablename WHERE manager='$manager'";
Link to comment
https://forums.phpfreaks.com/topic/277878-mysql_fetch_assoc/#findComment-1429507
Share on other sites

  On 5/10/2013 at 1:12 PM, mac_gyver said:

 

the syntax you are using for the $manager variable in the WHERE clause is adding dots . before and after the value, so your WHERE clause is false and is not matching anything.

 

you can put a php variable inside of a double quoted string. you also had single quotes around the column name in the SELECT clause, which would have literally returned the string 'manager' -

$query = "SELECT manager FROM tablename WHERE manager='$manager'";

 

Thank you Mac_Gyver! you absolute beauty, this solved it.

 

Thank you all for your help, this has had me going insane all day, happy Friday and have a good weekend all.

Link to comment
https://forums.phpfreaks.com/topic/277878-mysql_fetch_assoc/#findComment-1429512
Share on other sites

Archived

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

×
×
  • Create New...

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.