Jump to content

greencoin

Members
  • Posts

    72
  • Joined

  • Last visited

    Never

About greencoin

  • Birthday 08/01/1974

Contact Methods

  • MSN
    man_redeemed@hotmail.com

Profile Information

  • Gender
    Male
  • Location
    South Carolina

greencoin's Achievements

Member

Member (2/5)

0

Reputation

  1. I am humbled and ashamed... the original code used bar ticks but I changed them trying to figure out the problem. Wildbug.. You da schiz-nit! Thanks for your help, again. ~Rich
  2. Ok back - anyone have any suggestions? ~Rich
  3. Ahhh... you tell me. I believe the syntax is correct and the field + variables are correct too. Am going to bed now. Ttyl ~Rich
  4. ack! I keep forgettin my semicolons... here's what you're lookin for; SELECT * FROM GC_Tracker WHERE ("area" LIKE '%ak%' OR "area" LIKE '%LA%' ) whatcha think? ~Rich
  5. "Parse error: parse error, unexpected T_IF in http://./././track_area_results.php on line 16" <?php $name2 = $_POST['state']; for($name2array=0; $name2array < sizeof($name2); $name2array++) { if($name2array < (sizeof($name2)-1)) { $name2_cond = " OR "; } else { $name2_cond = ""; } $name2q = $name2q."\"area\" LIKE '%".$name2[$name2array]."%' $name2_cond"; } $name2q = "($name2q)"; $sql = "SELECT * FROM GC_Tracker WHERE $name2q"; die ($sql) if ($result = mysql_query($sql)) { // This is line 16 if (mysql_num_rows($result)) { $i = 0; echo "<TABLE width=\"850\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\">\n"; echo "<TR bgcolor=\"ccffcc\"><TD>ID</TD><TD width=130>Customer</TD><TD width=75>Area</TD><TD width=75>City</TD><TD width=100>Phone</TD><TD width=75>Amount</TD><TD>Units</TD></TR>\n"; while ($row = mysql_fetch_array($result)) { if ($i % 2) { echo "<TR bgcolor=\"ccffcc\">\n"; } else { echo "<TR bgcolor=\"white\">\n"; } echo "<TD>".$row['cid']."</TD><TD>".$row['customer']."</TD><TD>".$row['area']."</TD><TD>".$row['city']."</TD> <TD>".$row['phone']."</TD><TD>".$row['amount']."</TD> <TD>".$row['prod1'].", ".$row['prod2'].", ".$row['prod3'].", ".$row['prod4'].", ".$row['prod5'].", ".$row['prod6'].", ".$row['prod7'].", ".$row['prod8'].", ".$row['prod9'].", ".$row['prod10']."</TD>\n"; echo "</TR>\n"; $i++; } echo "</TABLE>\n"; echo "<br>\n"; echo "<input type=Button name=printit value=print onclick=javascript:window.print();>\n"; } else { echo "No results found"; } } else { echo "Query failed<br />" . $sql . "<br />" . mysql_error(); } ?> Thanks Wildbug ~Rich
  6. I recycled this code from a working page on the same website that queries MySQL for all records of a specific field. I don't think I'll need the == as I'm not comparing. I created an array that posts all row data with corresponding field data (supposed to). ~Rich
  7. HI! was getting another error but read about the mysql functions and since modified my code. Now I'm getting "No Results Found" which is one of the "else" returns as you'll see. <?php // db connect stuff goes here $name2 = $_POST['state']; for($name2array=0; $name2array < sizeof($name2); $name2array++) { if($name2array < (sizeof($name2)-1)) { $name2_cond = " OR "; } else { $name2_cond = ""; } $name2q = $name2q."\"area\" LIKE '%".$name2[$name2array]."%' $name2_cond"; } $name2q = "($name2q)"; $sql = "SELECT * FROM GC_Tracker WHERE $name2q"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $i = 0; echo "<TABLE width=\"850\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\">\n"; echo "<TR bgcolor=\"ccffcc\"><TD>ID</TD><TD width=130>Customer</TD><TD width=75>Area</TD><TD width=75>City</TD><TD width=100>Phone</TD><TD width=75>Amount</TD><TD>Units</TD></TR>\n"; while ($row = mysql_fetch_array($result)) { if ($i % 2) { echo "<TR bgcolor=\"ccffcc\">\n"; } else { echo "<TR bgcolor=\"white\">\n"; } echo "<TD>".$row['cid']."</TD><TD>".$row['customer']."</TD><TD>".$row['area']."</TD><TD>".$row['city']."</TD> <TD>".$row['phone']."</TD><TD>".$row['amount']."</TD> <TD>".$row['prod1'].", ".$row['prod2'].", ".$row['prod3'].", ".$row['prod4'].", ".$row['prod5'].", ".$row['prod6'].", ".$row['prod7'].", ".$row['prod8'].", ".$row['prod9'].", ".$row['prod10']."</TD>\n"; echo "</TR>\n"; $i++; } echo "</TABLE>\n"; echo "<br>\n"; echo "<input type=Button name=printit value=print onclick=javascript:window.print();>\n"; } else { echo "No results found"; // this is what it's spitting out } } else { echo "Query failed<br />" . $sql . "<br />" . mysql_error(); } ?> Could someone point me in the right direction to debug or point out the flaw in my code. The database is loaded so I should've had a result based on the input.
  8. ok - modified the code and now getting a different error. will close this and open another thread based on the new problem. Thanks for the help as always. ~Rich
  9. Trying to debug, I changed the code after finding some other people who posted the same errors. Now I have this code; <?php $name2 = $_POST['state']; for($name2array=0; $name2array < sizeof($name2); $name2array++) { if($name2array < (sizeof($name2)-1)) { $name2_cond = " OR "; } else { $name2_cond = ""; } $name2q = $name2q."\"area\" LIKE '%".$name2[$name2array]."%' $name2_cond"; } $name2q = "($name2q)"; $query = "SELECT * FROM GC_Tracker WHERE $name2q"; $sql = mysql_query($query) or die(mysql_error()); Print "<table width=860 border=1 cellpadding=0 cellspacing=0 class=table_results>"; Print "<tr bgcolor=ccffcc>"; Print "<td width=35>Order</td>"; Print "<td width=100>Customer</td>"; Print "<td width=75>Phone</td>"; Print "<td width=50>Area</td>"; Print "<td width=75>City</td>"; Print "<td width=70>Amount</td>"; Print "<td width=100>Products</td>"; Print "<td width=20>Created On</td></tr>"; while($info = mysql_fetch_array( $sql )) { Print "<tr bgcolor=ffffff>"; Print "<td>".$info['cid'] . "</td> "; Print "<td>".$info['customer'] . "</td> "; Print "<td>".$info['phone'] . " </td>"; Print "<td>".$info['area'] . " </td>"; Print "<td>".$info['city'] . "</td> "; Print "<td>".$info['amount'] . " </td>"; Print "<td>".$info['prod1']. " </td>"; $var = $info['time']; list($date,$time) = explode(' ',$var); Print "<td>".$date . " </td></tr>"; } echo $sql; // for debugging only to check my variable Print "</table>"; Print "<br>\n"; Print "<input type=Button name=printit value=print onclick=javascript:window.print();>\n"; ?> It no longer kicks out an error but the beginings of a table, with blank rows of course. I echoed $sql and it returns "Resource #2". die ($query) gives me; SELECT * FROM GC_Tracker WHERE ("area" LIKE '%LA%' ) I'm using MySQL 4.1 on godaddy servers... ~Rich
  10. bbaker: I tried your correction and die($query) gave me; SELECT * FROM GC_Tracker WHERE When I uncommented $name2q = "($name2q)"; it gave me; SELECT * FROM GC_Tacker WHERE () I DO need to find a field containing the variable so how would I pass the '%...%' to the SELECT statement? I forgot to mention the form that passes the $name2 variable is a multiple checkbox form that will pass more than one variable at a time. Thanks ~Rich
  11. Here's what I get "Query failed Resource id #2 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #2' at line 1" here's the code; <?php // db connect stuff $name2 = $_POST['state']; for($name2array=0; $name2array < sizeof($name2); $name2array++) { if($name2array < (sizeof($name2)-1)) { $name2_cond = " OR "; } else { $name2_cond = ""; } $name2q = $name2q."\"area\" LIKE'".$name2[$name2array]."'$name2_cond"; } $name2q = "($name2q)"; $query = "SELECT * FROM GC_Tracker WHERE $name2q"; die($query); $sql = mysql_query($query) or die(mysql_error()); if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $i = 0; echo "<TABLE width=\"850\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=cccccc>\n"; echo "<TR bgcolor=\"ccffcc\"><TD>ID</TD><TD width=130>Customer</TD><TD width=75>Area</TD><TD width=75>City</TD><TD width=100>Phone</TD><TD width=75>Amount</TD><TD>Units</TD></TR>\n"; while ($row = mysql_fetch_array($result)) { if ($i % 2) { echo "<TR bgcolor=\"ccffcc\">\n"; } else { echo "<TR bgcolor=\"white\">\n"; } echo "<TD>".$row['cid']."</TD><TD>".$row['customer']."</TD><TD>".$row['area']."</TD><TD>".$row['city']."</TD> <TD>".$row['phone']."</TD><TD>".$row['amount']."</TD> <TD>".$row['prod1'].", ".$row['prod2'].", ".$row['prod3'].", ".$row['prod4'].", ".$row['prod5'].", ".$row['prod6'].", ".$row['prod7'].", ".$row['prod8'].", ".$row['prod9'].", ".$row['prod10']."</TD>\n"; echo "</TR>\n"; $i++; } echo "</TABLE>\n"; echo "<br>\n"; echo "<input type=Button name=printit value=print onclick=javascript:window.print();>\n"; } else { echo "No results found"; } } else { echo "Query failed<br />" . $sql . "<br />" . mysql_error(); } // } else { // echo "form not submitted"; // } ?> The variables in the query are passing correctly. Using die($query) the string looks like; SELECT * FROM GC_Tracker WHERE ("area" LIKE'ak') Other than there is no space in between LIKE and the variable 'ak', I don't see anything wrong with the SELECT line. Anyone? Thanks in advance ~Rich
  12. OK again, figured out what I was doing wrong to cause the "Query was empty" <?php $result = mysql_query($query) or die(mysql_error()); \\ changed $result to $sql if ($result = mysql_query($sql)) \\ there is no $sql variable defined!! ?> Ahh, the joy of recycling code. Now I have a different error with a much more ominous error message that I'm going to post in a new thread. Thanks for the help Thorpe. Case closed! ~Rich
  13. OK - so I modified the code to; <?php $name2q = $name2q."\"area\" LIKE'".$name2[$name2array]."'$name2_cond"; // put area in doubles quotes } $name2q = "($name2q)"; $query = "SELECT * FROM GC_Tracker WHERE $name2q";?> which gives me the correct query output of; "SELECT * FROM GC_Tracker WHERE ("area" LIKE'ak') but it's still telling me the query failed, query was empty. I know the table has the info.. I tried a query with all 50 boxes checked, tried a query with one box checked (with a known matching record). I am now "officially" totally lost. ??? Anyone? ~Rich
  14. Very nice. Here's what I got with a single checkbox checked; SELECT * FROM GC_Tracker WHERE (`area` LIKE'ak') And with 2 checked; SELECT * FROM GC_Tracker WHERE (`area` LIKE'ak' OR `area` LIKE'la') Does this look right for MySQL 4.1? Aren't the single quotes supposed to be double quotes? ~Rich
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.