Jump to content

mysql_fetch_assoc() ?


managerstats
Go to solution Solved by mac_gyver,

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;

 

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
Share on other sites

  • Solution

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
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'";

 

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.