Call to undefined function getsqlvaluestring() with Dreamweaver PHP mysql
来源:互联网 发布:王侯将相焉有种乎出自 编辑:程序博客网 时间:2024/05/16 03:37
undefined function getsqlvaluestring()
Hey Guys, I'm new to the forum and it seems very helpful. I think I have a unique problem though.
Although this script has been working for a year or two, all of a sudden, over the holidays, it went hay
Front end is still getting all the information it should from the Database.But when I try to login through the admin side that I created with the normal dreamweaver php and database extensions I get this error.
I dont know a lot of php - so I'll hide the string for now - If I need to paste the code I will - thank you in advance
Fatal error: Call to undefined function getsqlvaluestring() in /xxxxx/xxxx/xxxxxxx/xxxxxxx/newsletters/xxxxxxx/xxxxxxx/admin/login.ph pon line 22
Area around line 22 looks like this
mysql_select_db($database_promocenter, $promocenter);
$LoginRS__query=sprintf("SELECT username, password, destination_page FROM users WHERE username=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "int"));
$LoginRS = mysql_query($LoginRS__query, $promocenter) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
Forms first part looks like this
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>"> <tr> <td bgcolor="#dedede"> <table width="400" border="0" align="center" cellpadding="3" cellspacing="0" bgcolor="#ffffff"> <tr> <td height="35" align="right" valign="middle" id="description">Username: </td> <td height="35"><label> <input style="height:20px; border:1px solid #999999" name="username" type="text" id="username" size="35"/> </label></td> </tr> <tr> <td height="35" align="right" valign="middle" id="description">Password: </td> <td height="35"><label> <input style="height:20px; border:1px solid #999999" name="password" type="password" id="password" size="35" /> </label></td> </tr>
Anton
The could as you show it could never have worked. Why? Because the call to the function is made before the function is defined! It would have always stopped execution with an undefined function error.
Now - it appears that you have added user authentication that placed itself before the code block in which the function is defined. So, I'd suggest you move this -
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
from its current location to a new block just under the connection include directive, i.e.,
<?php require_once('../Connections/promocenter.php'); ?>
<?php MOVE HERE ?>
<?php
// *** Validate request to login to this site.
so that the final code looks like this -
<?php require_once('../Connections/promocenter.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
?>
<?php
// *** Validate request to login to this site.
- 1.MurraySummers,2012-1-26 上午4:26 in reply to AntonsScreenNameReport
Let's see the PHP from the top 20 lines of code on your page, please (above the <html> tag).
Was this helpful? Yes NoTranslate - 2.AntonsScreenName,2012-1-26 上午4:29 in reply to MurraySummersReport
Thank you for your reply - the path is correct and the promocenter.php file only has the database details in
<?php require_once('../path/promocenter.php'); ?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "access_level";
$MM_redirectLoginSuccess = "index.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_promocenter, $promocenter);
Was this helpful? Yes NoTranslate - 3.MurraySummers,2012-1-26 上午4:48 in reply to AntonsScreenNameReport
Do you see code in that region that looks like this?
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
That's boilerplate code for the function that is always inserted by DW when you place a recordset on the page. The error message you are getting seems to suggest that the function definition is missing. I'm also a little troubled by the casing of the function name in the error message - it clearly does not match the casing shown here.
Was this helpful? Yes NoTranslate - 4.osgood_,2012-1-26 上午4:53 in reply to AntonsScreenNameReport
Seems you need a function() file. You must have another file somewhere that you have forgotten to include?
http://forums.digitalpoint.com/showthread.php?t=54786
Maybe you are using the same script that worked for another website but forgot to include the function() file???
Was this helpful? Yes NoTranslate - 5.AntonsScreenName,2012-1-26 上午4:55 in reply to MurraySummersReport
Hi Murray
Okay, seems like theres no reason for me to hide the code - the actual error is
Fatal error: Call to undefined function getsqlvaluestring() in/u1/home/comzttoj/public_html/newsletters/Resources/promocenter/admin/ login.php on line 22
and the code looks like this
<?php require_once('../Connections/promocenter.php'); ?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "access_level";
$MM_redirectLoginSuccess = "index.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_promocenter, $promocenter);
$LoginRS__query=sprintf("SELECT username, password, destination_page FROM users WHERE username=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "int"));
$LoginRS = mysql_query($LoginRS__query, $promocenter) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'access_level');
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<?php if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
mysql_select_db($database_promocenter, $promocenter);
$query_rs_users_login = "SELECT * FROM users";
$rs_users_login = mysql_query($query_rs_users_login, $promocenter) or die(mysql_error());
$row_rs_users_login = mysql_fetch_assoc($rs_users_login);
$totalRows_rs_users_login = mysql_num_rows($rs_users_login);
?>
Was this helpful? Yes NoTranslate - 6.AntonsScreenName,2012-1-26 上午4:56 in reply to osgood_Report
I dont think I forgot to include a file, as this code has been working for almost 2 years and all of a sudden over the holidays, without me even thinking of the code - it started giving me this error.
Was this helpful? Yes NoTranslate - 7.MurraySummers,2012-1-26 上午5:05 in reply to AntonsScreenNameReport
The could as you show it could never have worked. Why? Because the call to the function is made before the function is defined! It would have always stopped execution with an undefined function error.
Now - it appears that you have added user authentication that placed itself before the code block in which the function is defined. So, I'd suggest you move this -
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
from its current location to a new block just under the connection include directive, i.e.,
<?php require_once('../Connections/promocenter.php'); ?>
<?php MOVE HERE ?>
<?php
// *** Validate request to login to this site.
so that the final code looks like this -
<?php require_once('../Connections/promocenter.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
?>
<?php
// *** Validate request to login to this site.
Was this helpful? Yes NoTranslate - 8.osgood_,2012-1-26 上午5:11 in reply to AntonsScreenNameReport
Try moving the below to the top of the php code:
<?php if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
mysql_select_db($database_promocenter, $promocenter);
$query_rs_users_login = "SELECT * FROM users";
$rs_users_login = mysql_query($query_rs_users_login, $promocenter) or die(mysql_error());
$row_rs_users_login = mysql_fetch_assoc($rs_users_login);
$totalRows_rs_users_login = mysql_num_rows($rs_users_login);
?>
Was this helpful? Yes NoTranslate - 9.AntonsScreenName,2012-1-26 上午5:18 in reply to MurraySummersReport
Hi Murray - thank you for that, but what about
mysql_select_db($database_promocenter, $promocenter);
$query_rs_users_login = "SELECT * FROM users";
$rs_users_login = mysql_query($query_rs_users_login, $promocenter) or die(mysql_error());
$row_rs_users_login = mysql_fetch_assoc($rs_users_login);
$totalRows_rs_users_login = mysql_num_rows($rs_users_login);
Was this helpful? Yes NoTranslate - 10.osgood_,2012-1-26 上午5:22 in reply to AntonsScreenNameReport
AntonsScreenName wrote:
Hi Murray - thank you for that, but what about
mysql_select_db($database_promocenter, $promocenter);
$query_rs_users_login = "SELECT * FROM users";
$rs_users_login = mysql_query($query_rs_users_login, $promocenter) or die(mysql_error());
$row_rs_users_login = mysql_fetch_assoc($rs_users_login);
$totalRows_rs_users_login = mysql_num_rows($rs_users_login);
Thats not part of the function so you can leave that where it is. I just grabbed the whole lot.
Was this helpful? Yes NoTranslate - 11.AntonsScreenName,2012-1-26 上午5:21 in reply to AntonsScreenNameReport
By the way, If I do what Murray and Osgood said I get this error on the top of my page
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /u1/home/comzttoj/public_html/newsletters/Resources/promocenter/admin /login.php:66) in/u1/home/comzttoj/public_html/newsletters/Resources/promocenter/admin/ login.php on line 70
And if I log in with it anyway I get this
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /u1/home/comzttoj/public_html/newsletters/Resources/promocenter/admin /login.php:66) in/u1/home/comzttoj/public_html/newsletters/Resources/promocenter/admin/ login.php on line 70
Unknown column 'destination_page' in 'field list'
Was this helpful? Yes NoTranslate - 12.osgood_,2012-1-26 上午5:31 in reply to AntonsScreenNameReport
Have you got any white space between the blocks of php code or above the top line of the php code. This 'header already sent' warning usually pops up when the empty space above, below, inbetween in the php code is present.
You could also try adding the below piece of php to the very top of the page:
<? ob_start(); ?>
and this piece after the last closing ?> php tag on the page:
<? ob_flush(); ?>
Was this helpful? Yes NoTranslate - 13.AntonsScreenName,2012-1-26 上午5:33 in reply to osgood_Report
Okay thanks - it seems like we're getting somewhere - those session start warnings are gone, and looks great
However, when I finally try to login at login.php I get this error
Unknown column 'destination_page' in 'field list'
I do have a index.php page in the same folder as login.php
Was this helpful? Yes NoTranslate - 14.osgood_,2012-1-26 上午5:51 in reply to AntonsScreenNameReport
AntonsScreenName wrote:
Unknown column 'destination_page' in 'field list'
I do have a index.php page in the same folder as login.php
Is there a column in your database table 'users' with the name destination_page?
I can't see why you are selecting it from the database in the first instance?
$LoginRS__query=sprintf("SELECT username, password, destination_page FROM users WHERE username=%s AND password=%s",
Was this helpful? Yes NoTranslate - 15.AntonsScreenName,2012-1-26 上午5:53 in reply to osgood_Report
No Osgood - Ive got 3 tables logos / promotions / users
And none of them have a column called 'destination_page' << There is no such word in my database at all, anywhere
Was this helpful? Yes NoTranslate - 16.osgood_,2012-1-26 上午5:55 in reply to AntonsScreenNameReport
Well get rid of the call to it then:
Change this:
$LoginRS__query=sprintf("SELECT username, password, destination_page FROM users WHERE username=%s AND password=%s",
To this:
$LoginRS__query=sprintf("SELECT username, password FROM users WHERE username=%s AND password=%s",
Was this helpful? Yes NoTranslate - 17.AntonsScreenName,2012-1-26 上午5:57 in reply to AntonsScreenNameReport
Okay, that was stuff I pasted from another forum in the hope to help me, but that destination_page should actually have been access_level and I got to the index.php file as a logged in person, but now I have another issue - do you guys mind to help? Please
Was this helpful? Yes NoTranslate - 18.AntonsScreenName,2012-1-26 上午6:02 in reply to AntonsScreenNameReport
I did this
Changed this:
$LoginRS__query=sprintf("SELECT username, password, destination_page FROM users WHERE username=%s AND password=%s",
To this:
$LoginRS__query=sprintf("SELECT username, password, access_level FROM users WHERE username=%s AND password=%s",
As for the new problem, I did exactly on add-a-promo.php as I did on login.php
Thank you guys, for all your help, it's been great. Thank you Murray and Osgood_ - I've learnt something
Just so you know, the script did work for a year and a half without me touching the code and it just stopped working over the holidays. Could it have been upgrade to servers or os at hosting company?
Was this helpful? Yes NoTranslate - 19.osgood_,2012-1-26 上午6:11 in reply to AntonsScreenNameReport
AntonsScreenName wrote:
Just so you know, the script did work for a year and a half without me touching the code and it just stopped working over the holidays.
As Murray said earlier I fail to see how it could have worked because the function was declared after the call to the function which would throw an error. php has to be in the correct order to work as expected.
AntonsScreenName wrote:
Could it have been upgrade to servers or os at hosting company?
Probably unlikely but stranger things have happened. Not all servers work the same way as I've found out to my own frustrations recently.
Was this helpful? Yes No
- Call to undefined function getsqlvaluestring() with Dreamweaver PHP mysql
- php mysql Call to undefined function mysql_connect()
- Fatal error: Call to undefined function mysql_connect() (PHP连MYSQL)
- php连接mysql提示Call to undefined function mysql_connect()
- PHP连接MySQL错误:Call to undefined function mysql_connect()
- php连mysql报错:Call to undefined function mysql_connect()
- php-mysql配置---Call to undefined function mysql_connect()
- php连接mysql错误:Call to undefined function mysql_connect()
- [php] Call to undefined function bccomp
- PHP: Call to undefined function imageconvolution() 错误
- PHP:Call to undefined function curl_init()解决办法
- PHP-websocket Call to undefined function socket_create
- PHP :Call to undefined function mysql_connect()
- php ’Call to undefined function pcntl_fork‘
- PHP Call to undefined function mysql_connect()
- PHP错误:call to undefined function imagecreatetruecolor
- php+oracle Call to undefined function oci_connect
- 通联支付接口 undefined function: [php] Call to function bccomp
- “微风”团队的人员结构
- java的23种设计模式
- Hibernate实战_笔记29(每个类层次结构一张表)
- Android开发有关设置跳转网络设置界面出错的分析
- ActiveMQ集群:网络连接模式(network connector)详解
- Call to undefined function getsqlvaluestring() with Dreamweaver PHP mysql
- ceph的部署及遇到的问题
- 难为自己
- Unity中Mecanim工作流
- Qt进行UrlEncode/UrlDecode(URL编码/解码)
- 进程和线程之间的区别和联系总结
- 【metasearch学习笔记】Models for metasearch_SIGIR2001
- 基于 OpenLayers地图加载功能Javascript类定义
- 索引学习