Jump to content


Photo

PHP MYSQL


  • Please log in to reply
1 reply to this topic

#1 StirCrazy

StirCrazy
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 26 May 2006 - 01:53 PM

Can someone help me with the correct syntax for the following ~ not sure what i'm doing wrong.

trying to call username,sr_classifieds_score,sr_classifieds_pcnt and put them in $username,$score,$percentage

keep getting mysql_fetch_row(): supplied argument is not a valid MySQL result resource on line 15 - list($username,$score,$percentage) = mysql_fetch_row($r);

Thanks in advance.

S.C>

<?php

$db = "******";
$dbname = "*******";
$dbpass = "********";

$link = mysql_connect ('localhost', $dbname, $dbpass) or die;
@mysql_select_db('$db', $link);

function my_query($sql) {
  global $link;
  $result = @mysql_query($sql, $link);
  if ($result) return $result;

}

 $r = my_query("select username,sr_classifieds_score,sr_classifieds_pcnt  from user
  where userid='$user_id'");
  list($username,$score,$percentage) = mysql_fetch_row($r);

       @mysql_close( $link );
  
  ?>


#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,016 posts

Posted 26 May 2006 - 10:28 PM

@mysql_select_db('$db', $link);

Remove the single quotes from '$db'
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users