slappyjaw
09-04-2009, 04:09 AM
<?php require_once('../Connections/mysql.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
session_start();
$colname_friends = "-1";
if (isset($_SESSION['kt_login_user'])) {
$colname_friends = $_SESSION['kt_login_user'];
}
mysql_select_db("rubygir_slappyjaw");
if(!$mysql) {
echo 'Could not connect to the database.';
} else {
if(isset($_POST['queryString'])) {
if(strlen($queryString) >0) {
mysql_select_db($database_mysql, $mysql);
$query_friends = sprintf("SELECT * FROM friends WHERE (friend LIKE `{$queryString}` AND username = %s)", GetSQLValueString($colname_friends, "int"));
$friends = mysql_query($query_friends, $mysql) or die(mysql_error());
$row_friends = mysql_fetch_assoc($friends);
$totalRows_friends = mysql_num_rows($friends);
if($query = True) {
echo '<ul>';
while ($row_friends = $result) {
echo '<li onClick="fill(\''.$result['friend'].'\');">'.$result['friend'].'</li>';
}
echo '</ul>';
} else {
echo "We're sorry but you currently do not have any friends to message to.";
}
} else {
// do nothing
}
} else {
echo 'There should be no direct access to this script!';
}
}
mysql_free_result($friends);
?> For some reasion this script is returning a mysql error saying Unknown column '"ENTEREDVALUE"' in 'where clause'. this script allows users to select there friends from a ajax drop down list. Thank you for any help!:thumbsup:
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
session_start();
$colname_friends = "-1";
if (isset($_SESSION['kt_login_user'])) {
$colname_friends = $_SESSION['kt_login_user'];
}
mysql_select_db("rubygir_slappyjaw");
if(!$mysql) {
echo 'Could not connect to the database.';
} else {
if(isset($_POST['queryString'])) {
if(strlen($queryString) >0) {
mysql_select_db($database_mysql, $mysql);
$query_friends = sprintf("SELECT * FROM friends WHERE (friend LIKE `{$queryString}` AND username = %s)", GetSQLValueString($colname_friends, "int"));
$friends = mysql_query($query_friends, $mysql) or die(mysql_error());
$row_friends = mysql_fetch_assoc($friends);
$totalRows_friends = mysql_num_rows($friends);
if($query = True) {
echo '<ul>';
while ($row_friends = $result) {
echo '<li onClick="fill(\''.$result['friend'].'\');">'.$result['friend'].'</li>';
}
echo '</ul>';
} else {
echo "We're sorry but you currently do not have any friends to message to.";
}
} else {
// do nothing
}
} else {
echo 'There should be no direct access to this script!';
}
}
mysql_free_result($friends);
?> For some reasion this script is returning a mysql error saying Unknown column '"ENTEREDVALUE"' in 'where clause'. this script allows users to select there friends from a ajax drop down list. Thank you for any help!:thumbsup: