PDA

View Full Version : Dreamweaver not displaying stored URL on MYSQL


mangofreak
12-02-2012, 07:44 PM
Hi Guys,

I am facing an interesting issue. I have an insert form where I have the option to store a URL: http://www.mysite.com into a Mysql db just as a text datatype. MySQL shows the record has been stored but when I try to display the URL via a dynamic table or just by echoing it to a page it shows nothing. There is no error or warning, just it doesn't display at all.

I am using DWCS5
PHP Version 5.3.10
MySQL 5.5.28

Is that a bug or am I doing something wrong?
Everything else seems to work well - only the URL doesn't, if anyone has any ideas, please help.

mangofreak
12-02-2012, 08:55 PM
What a mistery.
I tested it in 2 different systems and only the records entered without an
absolute URL example:

http://www.mysite.com/products.php?cat=13&subcat=36

show as entered records. There must be something I'm missing. Do I have to encode the URL? Is this a DWCS5 issue or user error? Don't remember encountering this sort of problem before...

edbr
12-03-2012, 01:29 AM
me neither but this might be an answer for you http://stackoverflow.com/questions/6171822/php-trying-to-insert-urls-into-a-mysql-table

mangofreak
12-03-2012, 02:48 AM
Thanks for the reply EDBR. I checked your suggested link but I had no luck.

I'm not sure I am clear, so bear with me please...

I can safely store a URL in MySQL, using the insert record Wizard in DWCS5


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

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tblBanners (bannerName, fileURL, subcatID, otherURL, publish) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['bannerName'], "text"),
GetSQLValueString($_POST['fileURL'], "text"),
GetSQLValueString($_POST['subcatID'], "int"),
GetSQLValueString($_POST['otherURL'], "text"),
GetSQLValueString(isset($_POST['publish']) ? "true" : "", "defined","1","0"));

mysql_select_db($database_connProducts, $connProducts);
$Result1 = mysql_query($insertSQL, $connProducts) or die(mysql_error());

$insertGoTo = "banners.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}



within the initial code there is always a section that deals with the $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

I can see the stored data via Phpmyadmin therefore I know all is ok until that point. The problem is that, when I want to retrieve the record from mysql, DWCS5 doesn't seem to recognize that there is a record. It shows nothing.

The code to retrieve the record is working with other entries that use no url.
However, that same code doesn't work with otherURL
<?php echo $row_rsBanners['otherURL']; ?>

I have been searching in Google and have not come to anything close to solving the issue. If anyone has any ideas please let me know
cheers,

Javier

edbr
12-03-2012, 03:11 AM
does it show in browser though?

mangofreak
12-03-2012, 03:19 AM
Nope. When I called the php page where it supposed to appear, nothing shows.

It's very frustrating. No errors, nothing.

mangofreak
12-03-2012, 03:26 AM
BTW: your signature is great!
If you're happy and you know it shake your meds!

hehehe!

edbr
12-03-2012, 04:12 AM
sorry i dont have a clue if it is in the data base field it should echo out i would have thought. i assume the field is varchar , so it soungs like a validaton is stopping it somehow