PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 27th, 2003, 07:35 PM
seetherman seetherman is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 4 seetherman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Weird problem? PHP script works 'sometimes'

I am having a problem with this script,

Where a user can perform a search based on the values selected.

It is uploaded to my server now and it works fine. The form is filled in and the search works perfectly.

However, as soon as I leave the page and visit another page in my site, then return to the page it generates this error:

You have an error in your SQL syntax near 'AND weightCap BETWEEN ' at line 1

If I just use my back button to return to the page, again the script works fine. I can refresh the page and it still works. Why does it not work once I leave the page and return?

Here is the code:

PHP Code:
<?php include('lunaconnect.php'); ?>
<?php
mysql_select_db
($database_lunaconnect$lunaconnect);
$query_Recordset1 "SELECT * FROM catalog WHERE Manufacturer = '$Manufacturer' AND category = '$category' AND price BETWEEN $price AND weightCap BETWEEN $weightCap";
$Recordset1 mysql_query($query_Recordset1$lunaconnect) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?>

[code]<table width="100%" border="0">
    <tr> 
      <td bgcolor="#FFFFFF" class="unnamed2"> <p><font size="4"><img src="images/searchpink.gif" width="84" height="35"><br>
          Use the form below to locate your products</font></p>
        <form name="form1" method="post" action="">
          <table width="55%" border="0">
            <tr> 
              <td width="30%"><font color="#FF0000">Manufacturer</font></td>
              <td width="70%"> <select name="Manufacturer" id="Manufacturer">
                  <option value="Luna" selected>Luna</option>
                  <option value="Colson">Colson</option>
                  <option value="Harper">Harper</option>
                  <option value="Shepherd">Shepherd</option>
                  <option>Any</option>
                  <option value="Gamco">Gamco</option>
                  <option value="Plastiglide">Plastiglide</option>
                  <option value="Darnell">Darnell</option>
                  <option value="B & P">B & P</option>
                  <option value="Superior Components">Superior Comp.</option>
                  <option value="Rubbermaid">Rubbermaid</option>
                </select> </td>
            </tr>
            <tr> 
              <td><font color="#FF0000">Item Type</font></td>
              <td> <select name="category" id="category">
                  <option value="casters" selected>Caster</option>
                  <option value="carts">Cart</option>
                  <option value="wheels">Wheel</option>
                  <option value="ht">Hand Truck</option>
                  <option value="htwheels">Hand Truck/Lawn Wheel</option>
                  <option value="dollies">Dolly</option>
                  <option value="lifts">Lifts</option>
                </select></td>
            </tr>
            <tr> 
              <td><font color="#FF0000">Weight Capacity</font></td>
              <td> <select name="weightCap" id="weightCap">
                  <option value="1 AND 5000" selected>Any</option>
                  <option value="1 AND 50">Up to 50 lbs.</option>
                  <option value="1 AND 100">Up to 100 lbs.</option>
                  <option value="1 AND 200">Up to 200 lbs.</option>
                  <option value="1 AND 300">Up to 300 lbs.</option>
                  <option value="1 AND 400">Up to 400 lbs.</option>
                  <option value="1 AND 500">Up to 500 lbs.</option>
                  <option value="500 AND 1000">500 - 1000 lbs.</option>
                  <option value="1000 AND 9000">Over 1000 lbs.</option>
                </select></td>
            </tr>
            <tr> 
              <td width="25%"><font color="#FF0000">Price</font></td>
              <td width="75%"> <select name="price" id="price">
                  <option value="1 AND 9000" selected>Any</option>
                  <option value="1 AND 10">Less than $10</option>
                  <option value="1 AND 25">Up to $25</option>
                  <option value="1 AND 50">Up to $50</option>
                  <option value="1 AND 100">Up to $100</option>
                  <option value="1 AND 200">Up to $200</option>
                  <option value="1 AND 300">Up to $300</option>
                  <option value="1 AND 400">Up to $400</option>
                  <option value="1 AND 500">Up to $500</option>
                  <option value="500 AND 9000">Over $500</option>
                </select></td>
            </tr>
            <tr> 
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><input type="submit" name="Submit" value="Submit"></td>
            </tr>
          </table>
        </form>[/code]
You have an error in your SQL syntax near 'AND weightCap BETWEEN ' at line 1

Last edited by seetherman : February 27th, 2003 at 07:38 PM.

Reply With Quote
  #2  
Old February 28th, 2003, 04:15 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Paste the entire url address here when you get the error message... that may tell us why you have a problem.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old February 28th, 2003, 10:42 PM
seetherman seetherman is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 4 seetherman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
URL

This is the url address, now it generates this error everytime.

You have an error in your SQL syntax near 'AND weightCap BETWEEN ' at line 1

I can't see what is wrong with the code? Am I using the BETWEEN clause correctly?

This exact script was previously working, I changed nothing, and now it does not work.


Any ideas?

Reply With Quote
  #4  
Old March 2nd, 2003, 05:34 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
instead of

PHP Code:
AND price BETWEEN $price AND weightCap BETWEEN $weightCap 


try this instead

PHP Code:
AND price BETWEEN '$price' AND weightCap BETWEEN '$weightCap' 


That may help

Reply With Quote
  #5  
Old March 2nd, 2003, 09:05 PM
seetherman seetherman is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 4 seetherman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I figured out the problem...

I needed to declare the variables first, with some dummy values, like:

$price = 1 AND 2

$weightCap = 1 AND 2

Before I had updated the page with another script that had these values stored, so the script ran. Then when I exited the page and returned again the variables were empty and the script hanged.

Well, now it works.


Thanks-

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Weird problem? PHP script works 'sometimes'


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT