Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Wildcard in MySQL Query - Part 2

New Here ,
Oct 08, 2006 Oct 08, 2006
Thank's David.
Worked a treat. The key was uisng LIKE not =

However, while it works on the events page, when I try and do the same thing on a similar page, but for a different table, I have the following problem...

The SQL works fine, but as soon as I try and access the database from the page (i.e. using live data view of running the page on the website), i get the following error:

Fatal error: Call to undefined function: getsqlvaluestring() in /home/sites/enagri.info/public_html/enagri_info/news/#pagename# on line #line no.#

The line in question reads:
$query_rsNews = sprintf("SELECT newsDate, newsHeadline, newsLink, newsLocation, newsCategory FROM news WHERE newsLocation LIKE %s ORDER BY newsDate DESC", GetSQLValueString($location_rsNews, "text"));

Is this anthything to do with the fact that the values in the location table are integers and not text? However, it doesn't seem to be putting this code on the events page?

Any ideas?

P.S. - Haven't posted this a reply as when I try my browser keeps crashing.
P.P.S. - David, wasn't trying to say I didn't want to learn, but as a newbie, there's no halfway house. It sometimes seems that you end up having to learn adanced SQL from manuals that don't make sense, for a simple 4-line query...
🙂
TOPICS
Server side applications
395
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 08, 2006 Oct 08, 2006
rlc22 wrote:
> Fatal error: Call to undefined function: getsqlvaluestring() in
> /home/sites/enagri.info/public_html/enagri_info/news/#pagename# on line
> #line no.#
>
> Any ideas?

GetSQLValueString() is a custom-built Dreamweaver function. It's not
part of core PHP. You need to copy the function from a page with a
recordset in it and include it in your page.

> P.P.S. - David, wasn't trying to say I didn't want to learn, but as a newbie,
> there's no halfway house. It sometimes seems that you end up having to learn
> adanced SQL from manuals that don't make sense, for a simple 4-line query...

Fine. We all have to start learning somewhere. Unfortunately, there are
a lot of people who come to this forum with the attitude that they don't
want to learn. Working with any server-side language and SQL is a
massive subject. Dreamweaver can give a rapid boost to a beginner's
skills, but you do need to put in quite a bit of effort yourself if you
want to move beyond the basics.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 08, 2006 Oct 08, 2006
David, thanks.

I may be being thick, but the page already has a working recordset.

> GetSQLValueString() is a custom-built Dreamweaver function. It's not
> part of core PHP. You need to copy the function from a page with a
> recordset in it and include it in your page.

What am I looking to copy, and where does it need to go?



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 08, 2006 Oct 08, 2006
rlc22 wrote:
> I may be being thick, but the page already has a working recordset.

In that case, it was probably created with a version of Dreamweaver
prior to 8.0.2.

> What am I looking to copy, and where does it need to go?

This (it can go anywhere in your PHP page):

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;
}

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 09, 2006 Oct 09, 2006
LATEST


Thanks David
As you suggest, I had re-installed Dreamweaver, so I probably created the page without the 8.0.2 update installed. The text you list is notable by its presence on the other page.

I might just start the news page again as somehow I seem to have lost the repeating region and it seems to be using the GET function, rather than POST!!!

Great to get advice that a thicko like me can undestand and I'm looking forward to reading your book when Amazon deliver it!

Thanks again...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines