Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 11th, 2008, 11:43 AM
Registered User
 
Join Date: Jul 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with passing variable in php 5

Hi,

I'm stumped and hope someone here can help me

I have a php page with a search form that capture 2 variables 'where' and 'what'

I use a form on that page and capture the values in the form and pass them through the url to the search results page that queries my table and echoes back the search results.

Code:
<form action="advsearchresults.php" method="get">
The search results page is not providing any records when I know they exit. I see the variables in the ensuing url

I editing the query and swapped literal text for the variables and the query ran and echoed the records back. But it won't process the variables. Here is the top section of my code. I have tried everything and cannot figure it out. It worked previously in php 4 but stopped when the host upgraded to php 5

Code:
<?php require_once('Connections/dbh.php'); ?>
<?php
$maxRows_Recordset1 = 100;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

$colname_Recordset1 = "1";
if (isset($_POST[''])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_POST[''] : addslashes($_POST['']);
}

/* Test $what  & $where$GETVARs for empty. If either are empty, return to main page.
 * Not classy, but more graceful than MySQL error.
 */
if (!isset($_GET['what']) || !isset($_GET['where'] ))  {
    header("Location: index.php");
    exit();
    }

mysql_select_db($database_piercin, $dbh);
$query_Recordset1 = sprintf("SELECT * FROM gallery WHERE $_GET['where'] LIKE $_GET['what'] ORDER BY artist ASC", $colname_Recordset1);
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $dbh) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
  $all_Recordset1 = mysql_query($query_Recordset1);
  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
I also used to have wildcards in the 'what' of % and not sure if that would still work or not. I'm willing to up the "containing" and make people search for complete but would love to put that functionality back in also.

Thanks in advance.

Joy

Reply With Quote
  #2 (permalink)  
Old July 14th, 2008, 12:05 PM
Friend of Wrox
Points: 1,515, Level: 15
Points: 1,515, Level: 15 Points: 1,515, Level: 15 Points: 1,515, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Can you post the whole html form?

What is this trying to do:

$colname_Recordset1 = "1";
if (isset($_POST[''])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_POST[''] : addslashes($_POST['']);
}

We already know that your form is doing a GET, so this will always be "1".

--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
passing php variable to perl nriv08 PHP How-To 0 March 27th, 2008 10:38 AM
Passing javascript variable to html or php ashraf_gawdat Javascript How-To 3 July 12th, 2006 02:48 PM
Problem passing multiple arguments to php script method PHP How-To 0 February 8th, 2006 09:03 AM
passing php variable to javascript and vice versa onmcv Beginning PHP 0 March 24th, 2005 01:00 PM
Passing variable to a public variable Hudson40 Access VBA 2 February 25th, 2005 06:23 AM



All times are GMT -4. The time now is 04:41 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.