![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
DBookatay
-
Posts
334 -
Joined
-
Last visited
Posts posted by DBookatay
-
-
well considering you aren't showing where the dual equal sing is comming from your making it hard to guess whats wrong.
I dont understand what you mean, I showed all the code, or at least I thought I did...
-
$mysql_7daysago = date("Y-m-d G:i:s", strtotime("-7 Days")); if($_GET['status'] == "New") { $where[] = "submitted <= $mysql_7daysago"; } else { $where[] = "status = '{$_GET['status']}'"; }
Error: "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 '== 2008-01-17 20:37:38 and status = 'New' ORDER BY submitted DESC, ap_nmL ASC, a' at line 1"
-
mysql dates are a different format
<?php $mysql_7daysago = date("Y-m-d G:i:s", strtotime("-7 Days")); ?>
proper syntax for mysql 7 days ago date.
So how do I write my line? :
$where[] = "submitted $mysql_7daysago = date("Y-m-d G:i:s", strtotime("-7 Days"));";
-
I have a search page, that pulls data from my dB based on several criteria, and I want to add a new criteria: status = "New".
"New" meaning I have a field named "submitted" that when a user submits a form it uses "NOW()" and saves it as timestamp: "2007-03-19 19:22:21," I want "New" to pull all the forms submitted within the last 7 days, but I cant get my script to work correctly. Here is what I have:
$where[] = "submitted <= '" . date('Y-m-d', strtotime('-7 days')) . "'"; $query = "SELECT * FROM $table $where ORDER BY $order"; $result = mysql_query($query) or die(mysql_error()); if($result) { $numrows = mysql_num_rows($result); while($row = mysql_fetch_array($result)){ }
All of my other "$where[]" work correctly, so the only problem I have is determining what the 7 days are
"submitted <= '" . date('Y-m-d', strtotime('-7 days')) . "'";
Does anyone have any suggestions?
-
elseif ($row['body'] == "Dump" || $row['body'] == "Rack Body") {
Thank you, I had a brain fart and just couldnt figure it out...
-
if ($row['body'] == "Dump" OR == "Rack Body") { **** DO THIS *** }
How do you write an if statement like this?
I've tried:
if ($row['body'] == "Dump" OR "Rack Body") { **** DO THIS *** }
and:
if ($row['body'] == "Dump" || "Rack Body") { **** DO THIS *** }
neither of which work.
The full statement I am trying to do is:
if ($row['price_KBB'] != "0") { $kbbPrice = "$".number_format($row['price_KBB']); $kbb = "Yes"; } elseif ($row['body'] == "Dump" OR "Rack Body") { $kbbPrice = '<span class="red">*** N / A ***</span>'; $kbb = "Commercial"; } else { $kbb = "No"; }
-
as i said... it depends 100% on your site setup...
What do you mean? How is this done then?
-
Warning: Invalid argument supplied for foreach() in /home/.phillipina/dbookatay/carcityofdanbury.com/text.php on line 42a) this isnt a function... and b) it depends 100% on the rest of your page's setup...
for example
foreach($letters as $k=>$v){ if($k==$_GET[ltr]) $class='glossLtrOn'; else $class='glossLtr'; }
-
Hello all... I need help creating a function that will determine what css class should be used.
I am working on a Glossary page, that has a navigation menu on the right. (http://www.carcityofdanbury.com/text.php?category=Glossary&Ltr=A) I am trying to make it that if the user is under the "A" section, the nav link class
<a class="glossLtr" href="text.php?category=Glossary&Ltr=A">A</a>
is "glossLtrOn", and if it is not, say letter "B" it uses the default class: "glossLtr".
Any help would be appreciated.
-
You need to change the line to search the "term" Collum
so
$WHERE = "glossLtr LIKE('{$_GET['Ltr']}%')";
Becomes
$WHERE = "term LIKE('{$_GET['Ltr']}%')";
Scott.
Thats it, thanks Scott!
-
Where getting there...
I combined both AndyB and Scott's posts, and got this "error Unknown column 'glossLtr' in 'where clause' with query SELECT * FROM Glossary WHERE glossLtr LIKE('A%')
"
-
Try with this
SELECT * FROM News_Articles WHERE '$WHERE'
No good!
http://www.carcityofdanbury.com/text.php?category=Glossary&Ltr=A
-
I am creating a glossary of terms, and need help to execute the query.
In the dB there are 4 cells, 'id', 'term', 'deffination', and 'status'.
I have a nav with <a href="text.php?category=Glossary&Lrt=A">A</a> - <a href="text.php?category=Glossary&Lrt=Z">Z</a>, and want to make it if a user clicks a specific letter, all the terms that begin with that letter. Pretty simple right.
I though so...
Heres what I came up with:
if($_GET['category'] == "Glossary") { $Ltr = ($_GET['Ltr']); $glossLtr = substr($row['term'], 0, 1); $WHERE = "glossLtr = '{$_GET['Ltr']}'"; $query = "SELECT * FROM News_Articles $WHERE"; $result = mysql_query($query); $numrows = mysql_num_rows($result); while($row = mysql_fetch_array($result)){ $class = ($row_count % 2) ? $class2 : $class1; $id = $row['id']; $icon = '<img src="images/Common/Icons/new_Red.gif" />'; $glossTitle = stripslashes($row['title']); $content = stripslashes($row['content']); $pageContent .= $content; } }
All I keep getting is a parse error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/.phillipina/dbookatay/carcityofdanbury.com/text.php on line 42 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.phillipina/dbookatay/carcityofdanbury.com/text.php on line 43
What to do, what to do..?
-
I prefer some type of validation keyword.
Would you mind explaining?
-
I have several forms on my site that submits data into my dB, and lately more and more "spammers" are attacking them, posting everything from cheap viagra to "increased manhood..."
How can I edit my codes to prevent it from happening?
<?php function formatText($inputName,$text)//checks a givin field to see if its empty, if so change color and print it out. { if ($_SERVER['REQUEST_METHOD']=="POST") { if(empty($_POST[$inputName])) { echo "<span class='redBold'>" . $text . "</span>"; $_SESSION['ispassed']=false; } else { echo $text; } } else echo $text; } if (isset($_POST['nmF'])){ $time = time(); if (is_uploaded_file ($_FILES['image']['tmp_name'])) {if (move_uploaded_file($_FILES['image']['tmp_name'], "images/Testimonials/" . $time . "{$_FILES['image']['name']}")) $i = $time.$_FILES['image']['name'];} $query = "INSERT INTO Testimonials SET nmF = '$nmF', nmL = '$nmL', add1 = '$add1', add2 = '$add2', salesman = '{$_POST['salesman']}', year = '$vehYear', make = '$vehMake', model = '$vehModel', pic = '$i', comments = '$comments', status = 'on', posted = NOW(), ip = '{$_POST['ip']}'"; } if ($result = mysql_query ($query)) {} else {echo mysql_error();} if ($nmF && $nmL && $add1 && $add2 && $vehYear && $vehMake && $vehModel && $comments) echo "<meta http-equiv=\"Refresh\" content=\"0; url=testimonials.php\">"; ?>
-
Your post really has nothing to do with this topic
Parse error: syntax error, unexpected T_FOREACH in /home/.phillipina/dbookatay/carcityofdanbury.com/inventory_view2.php on line 386
Line 386:foreach($kbbs as $feature) {
-
Here is a simple multi column script. Replace the while statement with the loop for your array
<?php echo '<table border="0" CELLSPACING="0" CELLPADDING="10" align="center">'; //set 3 to 4 of you want 4 columns. Set it to 5 if you want 5, etc $numcols = 2; // how many columns to display $numcolsprinted = 0; // no of columns so far // get the results to be displayed $query = "SELECT sdate, type FROM dategroup ORDER BY sdate ASC"; $mysql_result = mysql_query($query) or die (mysql_error()); // get each row while($myrow = mysql_fetch_row($mysql_result)) { //get data - eg, reading fields 0 and 1 $tn = $myrow[0]; $in= $myrow[1]; if ($numcolsprinted == $numcols) { echo "</tr>\n<tr>\n"; $numcolsprinted = 0; } // output row from database echo "<td>$in $tn</td>\n"; // bump up row counter $numcolsprinted++; } // end while loop $colstobalance = $numcols - $numcolsprinted; for ($i=1; $i<=$colstobalance; $i++) { } echo "<TD></TD>\n"; echo "</table>; ?>
Ray
Ok, I'm following you so far, but where I have the "ftrs" echoing is already in a php string. Meaning:
if ($kbbPrice) { $right = '<div align="center"><table><tr><td><img src="images/Common/KBB/hdrL.gif" width="9" height="73" /><a href="http://www.kbb.com/KBB/UsedCars/'.$kbbValue.'" target="_blank"><img src="images/Common/KBB/hdrM.gif" width="153" height="73" /></a><img src="images/Common/KBB/hdrR.gif" width="204" height="73" /></td></tr><tr><td class="ContHldr" align="center"><div align="right" style="padding: 0 14 0 0"><img src="images/Common/KBB/bulletOff.gif" name="kbb001" /> <a onMouseOver="img2over(kbb001)" onMouseOut="img2out(kbb001)" class="KBB" href="http://www.kbb.com/KBB/UsedCars/'.$kbbValue.'" target="_blank">View Full Blue Book Report</a><br /><br /></div><div><img src="images/Common/KBB/hdr01.gif" /></div><br /><div align="center"><table width="345"><tr><td><img style="border: 1px solid #999999" src="'.$kbbImage.'" /></td><td rowspan="2"><img src="images/Common/spacer.gif" width="10" height="1" /></td><td rowspan="2"><table class="KBB1" width="170"><tr><td class="txt1">Condition</td><td class="txt1">Value</td></tr><tr class="KBB1"><td class="txt1"><font color="#000000">Excellent</font></td><td class="txt1" width="70">'.$kbbPrice.'</td></tr><tr><td class="KBB2" colspan="2"><b>Suggested Retail<br />Value Assumes<br />Excellent Condition...</b></td></tr></table></td></tr><tr><td style="padding: 5 0 0 0"><img src="images/Common/KBB/icon_Pic.gif" /> <a class="KBB" href="http://www.kbb.com/KBB/UsedCars/'.$kbbPics.'" target="_blank">More Photos</a></td></tr></table><p><table class="KBB2" width="345"><tr><td><div id="KBB1"><table width="328"><tr class="KBB2"><td class="txt2">Average Consumer Rating</td><td valign="middle" rowspan="2"><img src="images/Common/KBB/bulletOff.gif" name="kbb002" /> <a class="KBB" onMouseOver="img2over(kbb002)" onMouseOut="img2out(kbb002)" href="http://www.kbb.com/KBB/UsedCars/'.$kbbRatings.'" target="_blank">Read Reviews</a><br /><br /><img src="images/Common/KBB/bulletOff.gif" name="kbb003" /> <a class="KBB" onMouseOver="img2over(kbb003)" onMouseOut="img2out(kbb003)" href="http://www.kbb.com/KBB/UsedCars/'.$kbbRatings.'" target="_blank">Review This Vehicle</a></td></tr><tr><td height="46">'.$kbbRating.'</td></tr></table></div></td></tr></table><p><table class="KBB2" width="345"><tr><td><div id="KBB1"><table><tr class="KBB22"><td class="txt2" colspan="2">Vehicle Highlights</td></tr><tr><td height="20" width="90"><b>Mileage:</b></td><td height="20" width="255">'.$mileage.'</td></tr><tr><td height="20" width="90"><b>Engine:</b></td><td height="20" width="255">'.$kbbEng.'</td></tr><tr><td height="20" width="90"><b>Transmission:</b></td><td height="20" width="255">'.$kbbTrans.'</td></tr><tr><td height="20" width="90"><b>Drivetrain:</b></td><td height="20" width="255">'.$kbbDrive.'</td></tr></table></div></td></tr></table><p><table class="KBB2" width="345"><tr><td><div id="KBB1"><table><tr class="KBB2"><td class="txt2" colspan="3">Selected Equipment</td></tr><tr><td height="30" width="345" colspan="3"><b>Standard</b></td></tr>'.$standard.$optional.'</div></td></tr></table></div><div id="KBB2" align="left">* Connecticut '.$today.'</div></td></tr><tr><td><img src="images/Default/Titles/btm365.gif" /></td></tr></table></div><p>'; }
So how do I edit the script to not "echo" but return it as "$standard"?
-
The way you had the array was co
<?php $kbbS_features = array( 'ftr_001' => 'Air Conditioning', 'ftr_002' => 'Telescoping Wheel', 'ftr_003' => 'ABS (4-Wheel)', 'ftr_004' => 'Tilt', 'ftr_005' => 'Power Windows', 'ftr_006' => 'Power Seat (D)', 'ftr_007' => 'Auto Climate Control', 'ftr_008' => 'Telescoping Wheel', 'ftr_009' => 'Power Door Locks', 'ftr_010' => 'Power Seat (P)', 'ftr_011' => 'Navigation System', 'ftr_012' => 'Rear Spoiler', 'ftr_013' => 'Power Mirrors', 'ftr_014' => 'Heated Seats (F)', 'ftr_015' => 'DVD System', 'ftr_016' => 'Power Steering', 'ftr_017' => 'Dual Front Airbags', 'ftr_018' => 'Bluetooth Wireless', 'ftr_019' => 'Cruise Control', 'ftr_020' => 'Side Airbags (F)', 'ftr_021' => 'Parking Sensors', 'ftr_022' => 'Sunroof', 'ftr_023' => 'Side Airbags (R)', 'ftr_024' => 'Alloy Wheels' ); $kbbs = ''; foreach($row as $feature) { $feature_contains = substr($feature, 0, 4); if($feature_contains == 'ftr_') if($value == 'x') { $kbbs .= '"' . $kbbS_features[$feature] . '",'; } } } $kbbs = substr($kbbs, 0, strlen($kbbs)-1); $kbbs = explode(',', $kbbs); ?>
After you have done this you have an array of all of that vehicles features.
now when you go to echo this you would do a:
<?php foreach($kbbs as $feature) { print $feature . '<br />'; } ?>
which should show you all of your dream cars features
Problem is, I need the "$features" to not just print, but to print into its own cell, meaning:
<tr> <td>Air Conditioning</td> <td>Telescoping Wheel</td> </tr> <tr> <td>ABS (4-Wheel)</td> <td>Navigation System</td> </tr> <tr> <td>Dual Front Airbags</td> <td>Alloy Wheels</td> </tr>
and if its an uneven amount
<tr> <td>Air Conditioning</td> <td>Telescoping Wheel</td> </tr> <tr> <td>ABS (4-Wheel)</td> <td>Navigation System</td> </tr> <tr> <td colspan="2">Alloy Wheels</td> </tr>
-
You are giving me nothing at all to work with. I see variables but i have no idea what the variables are and therefore cannot help you. so if you want help then give us the whole thing
This was the old code, then someone rewrote it to make it more efficent:
foreach ($row as $feature => $value) {if (substr($feature, 0,== "feature_") { if ($feature == "feature_AC") {if ($value == "x") {$features[] = "Air Conditioning";}} if ($feature == "feature_PW") {if ($value == "x") {$features[] = "Power Windows";}} if ($feature == "feature_PDL") {if ($value == "x") {$features[] = "Power Door Locks";}} if ($feature == "feature_PM") {if ($value == "x") {$features[] = "Power Mirrors";}} if ($feature == "feature_CC") {if ($value == "x") {$features[] = "Cruise Control";}} if ($feature == "feature_SR") {if ($value == "x") {$features[] = "Sunroof";}} if ($feature == "feature_LS") {if ($value == "x") {$features[] = "Leather Seats";}} if ($feature == "feature_PS") {if ($value == "x") {$features[] = "Power Seat(s)";}} if ($feature == "feature_HFS") {if ($value == "x") {$features[] = "Heated Front Seats";}} if ($feature == "feature_HRS") {if ($value == "x") {$features[] = "Heated Rear Seats";}} if ($feature == "feature_TW") {if ($value == "x") {$features[] = "Tilt Steering Wheel";}} if ($feature == "feature_TCW") {if ($value == "x") {$features[] = "Telescoping Wheel";}} if ($feature == "feature_KE") {if ($value == "x") {$features[] = "Keyless Entry";}} if ($feature == "feature_TRS") {if ($value == "x") {$features[] = "Third Row Seating";}} if ($feature == "feature_RS") {if ($value == "x") {$features[] = "Remote Start";}} if ($feature == "feature_SP") {if ($value == "x") {$features[] = "Snow Plow";}} if ($feature == "feature_RR") {if ($value == "x") {$features[] = "Roof Rack";}} if ($feature == "feature_AW") {if ($value == "x") {$features[] = "Alloy Wheels";}} if ($feature == "feature_FL") {if ($value == "x") {$features[] = "Fog Lights";}} if ($feature == "feature_BL") {if ($value == "x") {$features[] = "Bed Liner";}} if ($feature == "feature_HID") {if ($value == "x") {$features[] = "H.I.D Lights";}} if ($feature == "feature_PG") {if ($value == "x") {$features[] = "Privacy Glass";}} if ($feature == "feature_TP") {if ($value == "x") {$features[] = "Tow Package";}} if ($feature == "feature_GPS") {if ($value == "x") {$features[] = "GPS System";}} if ($feature == "feature_NS") {if ($value == "x") {$features[] = "Navigation System";}} if ($feature == "feature_DVD") {if ($value == "x") {$features[] = "DVD System";}} if ($feature == "feature_TA") {if ($value == "x") {$features[] = "Theft Alarm";}} if ($feature == "feature_ABS") {if ($value == "x") {$features[] = "Anti-Lock Brakes";}} if ($feature == "feature_FAB") {if ($value == "x") {$features[] = "Dual Front Airbags";}} if ($feature == "feature_SCF") {if ($value == "x") {$features[] = "Side Curtin Airbags (F)";}} if ($feature == "feature_SCR") {if ($value == "x") {$features[] = "Side Curtin Airbags (R)";}} if ($feature == "feature_DCC") {if ($value == "x") {$features[] = "Dual Climate Control";}} if ($feature == "feature_PAP") {if ($value == "x") {$features[] = "Power Adjustable Pedals";}} if ($feature == "feature_MS") {if ($value == "x") {$features[] = "Memory Seats(s)";}} if ($feature == "feature_OS") {if ($value == "x") {$features[] = "OnStar";}} if ($feature == "feature_HL") {if ($value == "x") {$features[] = "HomeLink";}} }}
The the display
<?php for($x=0; $x<count($features);$x++) { if($x%2==0){echo "<table width=\"100%\"><tr>";} echo "<td class=\"vehFtrs\"><img src=\"images/Common/KBB/bulletOn.gif\" /> {$features[$x]}</td>"; if($x%2==1){echo "</tr></table>";} } if($x%2==1) {echo "<td> </td></tr></table>";} ?>
-
I posted this topic about a week ago, but no one could give me an answer why only the first "ftr" (Air Conditioning) is showing up, and nothing else. (Here is a working example: http://www.carcityofdanbury.com/inventory_view2.php?stock=15984 Under "Selected Equipment")
$kbbS_features = array( 'ftr_001' => 'Air Conditioning', 'ftr_002' => 'Telescoping Wheel', 'ftr_003' => 'ABS (4-Wheel)', 'ftr_004' => 'Tilt', 'ftr_005' => 'Power Windows', 'ftr_006' => 'Power Seat (D)', 'ftr_007' => 'Auto Climate Control', 'ftr_008' => 'Telescoping Wheel', 'ftr_009' => 'Power Door Locks', 'ftr_010' => 'Power Seat (P)', 'ftr_011' => 'Navigation System', 'ftr_012' => 'Rear Spoiler', 'ftr_013' => 'Power Mirrors', 'ftr_014' => 'Heated Seats (F)', 'ftr_015' => 'DVD System', 'ftr_016' => 'Power Steering', 'ftr_017' => 'Dual Front Airbags', 'ftr_018' => 'Bluetooth Wireless', 'ftr_019' => 'Cruise Control', 'ftr_020' => 'Side Airbags (F)', 'ftr_021' => 'Parking Sensors', 'ftr_022' => 'Sunroof', 'ftr_023' => 'Side Airbags (R)', 'ftr_024' => 'Alloy Wheels' ); foreach ($row as $ftr => $value) if (substr($ftr, 0,4)== 'ftr_' && $value == 'x') $kbbS[] = $kbbS_features[$ftr]; $standard = ""; for($x=0; $x<count($ftr);$x++) { if($x%2==0){$standard .= "<table><tr>";} $standard .= "<td height=\"20\" width=\"115\">{$kbbS[$x]}</td>"; if($x%2==1){$standard .= "</tr></table>";} } if($x%2==1) {$standard .= "<td> </td></tr></table>";}
Else where in the code I have the <? echo $standard; ?> echoed, but only Air Conditioning is showing up. And on the test example all 24 "ftr"s are available.
-
Looking at the script you created, leaves me with a question I always wondered.
I used to use the redirect php script
echo "<meta http-equiv="Refresh" content="0; url=inventory.php?status=Good">
but it seams like the java version
<HEAD><SCRIPT language="JavaScript1.1">location.replace("inventory.php?status=Error#StayUpdated");</SCRIPT></HEAD>
works much quicker.
Anyone care to comment?
-
try
f(isset($_POST['updated'])){ if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})", $_POST['updated'])) { echo '<HEAD><SCRIPT language="JavaScript1.1">location.replace("inventory.php?status=Error#StayUpdated");</SCRIPT></HEAD>'; } else{ $email = $_POST['updated']; $querySubmit; $querySubmit = mysql_query("INSERT INTO RecieveUpdates (email) VALUES ('$email')")or die(mysql_error()); echo "<meta http-equiv=\"Refresh\" content=\"0; url=inventory.php?status=Good\">"; } }
Thats it, thanks...
-
Ok, now the script is working, however it is still not 100%.
Even if the user does not enter an email address, and the default "Enter Email Address" is in the field, it still inserts "Enter Email Address" into the dB, instead of blocking it with errors...
-
change
if(!(empty($_POST['updated']))) {
to
if($_POST['updated'] != "") {
It still redirectes the user, as soon as the page loads, even if the submit button is not pressed
[SOLVED] Can't figure out this error...
in PHP Coding Help
Posted
I keep getting an error "Parse error: syntax error, unexpected ';' in /home/.phillipina/dbookatay/carcityofdanbury.com/inventory_search.php on line 415" and can't figure it out.
Basically, if $purDate is less than or equal to todays date, do this...