whats wrong with this code?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

whats wrong with this code?

Post by nite4000 »

hey everyone.

I have this code here

Code: Select all

session_start();
require_once('inc/db.php');
$dbc = db_connect();
require_once('inc/initialize.inc.php');
include('inc/functions.php');

require_once('inc/db_license.php');//the one created
$dbc2 = db_connect2();


$domain = $_SERVER['HTTP_HOST'];

[b]$query =mysql_query("SELECT domain FROM license",$dbc2); //$dbc is another database
$row = mysql_query($query, MYSQL_ASSOC);
@mysql_free_result($query);[/b]
now the part in bold i would normally write it as

Code: Select all

  $q = mysql_query("SELECT * FROM table") or die(mysql_error());
  $something = mysql_fetch_array($q, MYSQL_ASSOC);
  @mysql_free_result($q);

but when i do run it as is i get this error here

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/jwwwainv/public_html/d1/index.php on line 16
and line 16 would be

Code: Select all

$row = mysql_query($query, MYSQL_ASSOC);
i dont know if i am just trying to select from the table the wrong way or what. but everything else seems to be fine. i did echo the $row['domain'] and nothing showed so its gota be how i am doing it so if anyone has any ideas please help.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: whats wrong with this code?

Post by AbraCadaver »

MYSQL_ASSOC is used with mysql_fetch_array() which is what you want to fetch a row. Or mysql_fetch_assoc().
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply