Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 1st, 2004, 10:33 AM
Authorized User
 
Join Date: Nov 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jefferis Send a message via AIM to jefferis Send a message via MSN to jefferis
Default Variable Value fails to transmit

I'm having a lot of trouble with PHP Master Pages Detail Set in MX 2004 Testing page here. On pressing the link on the left, the value is passing to the pop up window [visible at the top bar], but I'm getting an error on the actual record item "Unknown column 'BR' in 'where clause'" These catalog values for items have a value like:
BR-13-02 . It appears that the post page is picking up the item ID, the record ID, and getting hammered by the initial value in the string. I've used Encoding and tried to protect against perhaps the error of a misunderstood hyphen, but it doesn't appear to help. It was suggested I seek help here.

// Initial page code

<td align="center"><a href="whatsup.php?recordID =<?php echo $row_Recordset1['item']; ?>"> <?php echo urlencode($row_Recordset1['item']); ?>&nbsp; </a> </td>
<td align="center"><?php echo $row_Reco rdset1['item_name']; ?>&nbsp; </td>

//and here is the popup page's code whose qu ery cannot find a value for $recordID:

<?php require_once('Connections/jodenonline.php'); ?><?php
$maxRows_DetailRS1 = 1;
$pageNum_DetailRS1 = 0;
if (isset($_GET['pageNum_DetailRS1'])) {
$pageNum_DetailRS1 = $_GET['pageNum_DetailRS1'];
}
$startRow_DetailRS1 = $pageNum_DetailRS1 * $ma xRows_DetailRS1;

mysql_select_db($database_jodenonline, $jodenonli ne);
$query_DetailRS1 = "SELECT* FROM `Catalog` WHERE `Catalog`.item = $recordID";
$query_limit_DetailRS1 = sprintf("%s LIMIT %d, %d", $query_DetailRS1, $startRow_DetailRS1, $ maxRows_DetailRS1);
$DetailRS1 = mysql_query($query_limit_DetailRS1, $jodenonline) or die(mysql_error());
$row_DetailRS1 = mysql_fetch_assoc($DetailRS1);

if (isset($_GET['totalRows_DetailRS1'])) {
$totalRows_DetailRS1 = $_GET['totalRows_DetailRS1'];
} else {
$all_DetailRS1 = mysql_query($query_DetailRS 1);
$totalRows_DetailRS1 = mysql_num_rows($all_D etailRS1);
}
$totalPages_DetailRS1 = ceil($totalRows_DetailRS 1/$maxRows_DetailRS1)-1;

$colname_Recordset1 = "1";
if (isset($_GET['recordID'])) {
$colname_Recordset1 = (get_magic_quotes_gpc( )) ? $_GET['recordID'] : addslashes($_GET['recordID']);
}
mysql_select_db($database_jodenonline, $jodenonli ne);
$query_Recordset1 = sprintf("SELECT * FROM `C atalog` WHERE item = '%s'", $colname_Recordse t1);
$Recordset1 = mysql_query($query_Recordset1, $j odenonline) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1) ;
$totalRows_Recordset1 = mysql_num_rows($Recordse t1);

~~~~~~~~~~~~~
I'd rather be drawing...
http://www.designswonders.com
__________________
~~~~~~~~~~~~~
&nbsp;http://www.petersonsales.net
 
Old September 1st, 2004, 04:07 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

We may be more willing to help if you format your code so as it is easy to read.
http://p2p.wrox.com/topic.asp?TOPIC_ID=11967



Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
 
Old September 1st, 2004, 06:05 PM
Authorized User
 
Join Date: Nov 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jefferis Send a message via AIM to jefferis Send a message via MSN to jefferis
Default

Quote:
quote:Originally posted by richard.york
 We may be more willing to help if you format your code so as it is easy to read.
http://p2p.wrox.com/topic.asp?TOPIC_ID=11967

Regards,
Rich
Sorry. I was trying to clip from the page the relevant code and minimize it.
Let me try again.

//Initial page code to transmit value which does transmit correct item# to page name:

    < a href="whatsup.php?recordID=<?php echo $row_Recordset1['item']; ?>">
             <?php echo urlencode($row_Recordset1['item']); ?> </a>
     <?php echo $row_Recordset1['item_name']; ?>


//and here is the popup page's code whose query cannot find a value for $recordID:

<?php require_once('Connections/jodenonline.php'); ?>
<?php
        $maxRows_DetailRS1 = 1;
        $pageNum_DetailRS1 = 0;

    if (isset($_GET['pageNum_DetailRS1'])) {
          $pageNum_DetailRS1 = $_GET['pageNum_DetailRS1'];
    }

    $startRow_DetailRS1 = $pageNum_DetailRS1 * $maxRows_DetailRS1;
    $colname_DetailRS1 = "1";

    if (isset($_GET['item'])) {
          $colname_DetailRS1 = (get_magic_quotes_gpc()) ? $_GET['item'] : addslashes($_GET['item']);
    }

        mysql_select_db($database_jodenonline, $jodenonline);
        $query_DetailRS1 = sprintf("SELECT * FROM `Catalog` WHERE item = $recordID",$colname_Recordset1);
        $query_limit_DetailRS1 = sprintf("%s LIMIT %d, %d", $query_DetailRS1, $startRow_DetailRS1, $maxRows_DetailRS1);
        $DetailRS1 = mysql_query($query_limit_DetailRS1, $jodenonline) or die(mysql_error());
        $row_DetailRS1 = mysql_fetch_assoc($DetailRS1);

    if (isset($_GET['totalRows_DetailRS1'])) {
          $totalRows_DetailRS1 = $_GET['totalRows_DetailRS1'];
    } else {
          $all_DetailRS1 = mysql_query($query_DetailRS1);
          $totalRows_DetailRS1 = mysql_num_rows($all_DetailRS1);
    }

$totalPages_DetailRS1 = ceil($totalRows_DetailRS1/$maxRows_DetailRS1)-1;

?>

~~~~~~~~~~~~~
I'd rather be drawing...
http://www.designswonders.com
 
Old September 1st, 2004, 07:35 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

When you click this URL..
    < a href="whatsup.php?recordID=<?php echo $row_Recordset1['item']; ?>">

..the data assigned to recordID becomes available in the $_GET superglobal in that script.

So, where ever you reference that variable you need to change to GET.. such as:
Code:
        $query_DetailRS1 = sprintf("SELECT * FROM `Catalog`  WHERE item = {$_GET['recordID']}",$colname_Recordset1);
A super global array exists for each method of input, GET, POST and COOKIE, as well as for some other special classifications of data.
http://www.php.net/manual/en/languag...predefined.php

The curly braces around the variable allows the array to be referenced within a string.
http://www.php.net/manual/en/language.types.string.php

HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
 
Old September 2nd, 2004, 07:20 AM
Authorized User
 
Join Date: Nov 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jefferis Send a message via AIM to jefferis Send a message via MSN to jefferis
Default

Hi Rich, I tried this solution, but it still fails. I wonder if that is the problem because my host's server has register globals ON by default. It also has magic quotes OFF, so I wonder if this line is causing the code to fail:
f (isset($_GET['recordID'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
}

~~~~~~~~~~~~~
 http://www.petersonsales.net
 
Old September 2nd, 2004, 07:30 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

It looks fine to me. The best way to answer that question, is if you are seeing any DB errors.

register_globals on or off won't affect what's available in superglobals.

If all else fails, just start outputting the value of each variable to see what's going wrong and where.

Sorry I couldn't be of more help.

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
 
Old September 2nd, 2004, 08:31 AM
Authorized User
 
Join Date: Nov 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jefferis Send a message via AIM to jefferis Send a message via MSN to jefferis
Default

Yes I am seeing a DB error. If I click on the first item in the returned list, I get an error that says check manual for MySql for ... 'jpg. Limit 0,1' and the other error being returned on all other items is Unknown column 'B' in 'where clause'...
I fixed the first error by removing .jpg from the ID name. This db works fine with other pages I've created, so I don't think it is the db, but there is something in this code that appears to be misinterpreting the record id info. A typical ID is an ITEM number , like B-02-04. Can you think of any query that will be offset or confused by a hyphen or by an encoded request that returns an item with a hyphen? It is almost as if the query is interpreting the hyphens as tabs or delimiters...

Jeff

~~~~~~~~~~~~~
 http://www.petersonsales.net





Similar Threads
Thread Thread Starter Forum Replies Last Post
Object variable or With block variable not set haidee_mccaffrey Classic ASP Professional 5 March 8th, 2007 03:34 PM
ASSIGNING A JAVA SCRIPT VARIABLE TO A XSL VARIABLE SOMANATHAN10 XSLT 1 February 21st, 2007 04:26 AM
Object variable or with block variable not set netfresher VS.NET 2002/2003 0 July 10th, 2006 02:44 AM
object variable or with block variable not set Aoude BOOK: Beginning VB.NET Databases 1 February 24th, 2006 05:21 PM
Receiving XML Transmit RobinR Classic ASP XML 1 July 16th, 2003 03:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.