Jump to content

Recommended Posts

Hello please help me out

 

I am getting this error " mysql_query(): supplied argument is not a valid MySQL-Link resource in"

I don't understand why my query is good I have tested it in phpMyAdmin and runs fine so why am I getting this error

 

// Protect Variables from SQL injection
function checkVars($value){
// Stripslashes
if (get_magic_quotes_gpc()){
 	$value = stripslashes($value);
}
// Quote if not a number
if (!is_numeric($value)){
	$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
};

// set Variables
$clientID = checkVars($_GET['clientID']);

mysql_select_db($database_admin , $admin);


function photoCount($saleState, $clientID){
$SQL_countPhotos = "SELECT COUNT(photos.photoID), photos.saleState, photos.clientId FROM photos WHERE photos.saleState = '$saleState' AND photos.clientId = '$clientID'";
$rs_countPhotos= mysql_query($SQL_countPhotos, $admin);
$row_countPhotos = mysql_fetch_assoc($rs_countPhotos);
//echo $SQL_countPhotos;
echo $row_countPhotos['COUNT(photos.photoID)'];
}

This is easier on the eyes.

<?php
// Protect Variables from SQL injection
function checkVars($value){
// Stripslashes
if (get_magic_quotes_gpc()){
	$value = stripslashes($value);
}
// Quote if not a number
if (!is_numeric($value)){
	$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
};

// set Variables
$clientID = checkVars($_GET['clientID']);

mysql_select_db($database_admin , $admin);


function photoCount($saleState, $clientID){
$SQL_countPhotos = "SELECT COUNT(photos.photoID), photos.saleState, photos.clientId FROM photos WHERE photos.saleState = '$saleState' AND photos.clientId = '$clientID'";
$rs_countPhotos= mysql_query($SQL_countPhotos, $admin);
$row_countPhotos = mysql_fetch_assoc($rs_countPhotos);
//echo $SQL_countPhotos;
echo $row_countPhotos['COUNT(photos.photoID)'];
}
?>

Okay.. i'll let you work it out,

but first think about these two questions

#1 what is $admin.

and

#2 What does the error say is invalid ?

 

and i assume this works when they are not in their own functions

 

idea..

global $admin;

 

EDIT: awww Ken2k7!! lol

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.