Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. You didn't make my change. Change this line: if(isset($_POST['submit'])){ To: if(isset($_POST['Submit'])){ Note the capital S.
  2. A host that does support cronjobs may well not allow use of the exec() function though.
  3. Why are you using a text field to store a price anyway?
  4. Sorry, that would be my fault - didn't notice you'd capitalized the first letter of the name of the submit button - hence the if(isset()) was always failing. Try: <form method="POST" action="search.php"> <input type="text" name="search" size=25 maxlength=25> <input type="Submit" name="Submit" value="Submit"> </form> <?php mysql_connect("localhost", "XXXXX", "XXXXX"); mysql_select_db("XXXXX"); if(isset($_POST['Submit'])){ $search=$_POST["search"]; $result = mysql_query("SELECT name FROM item_template WHERE name LIKE '%$search%'") or die(mysql_error()); if(mysql_num_rows($result) > 0){ while($r=mysql_fetch_array($result)) { $name=$r["name"]; echo "$name<br>"; } }else{ echo 'No matching items found!'; } } ?> Indeed - not sure where that came from!
  5. I think you may also need to specify the COOKIEFILE option before your second request: curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt"); Did you also add things like a referrer and user agent? Certain(bad) websites will check these and not show data if they're not present.
  6. Can you post your updated code please?
  7. This means that either your query is failing, or there are no rows returned. Try modifying your query to this: <form method="POST" action="search.php"> <input type="text" name="search" size=25 maxlength=25> <input type="Submit" name="Submit" value="Submit"> </form> <?php mysql_connect("localhost", "XXXXX", "XXXXX"); mysql_select_db("XXXXX"); if(isset($_POST['submit'])){ $search=$_POST["search"]; $result = mysql_query("SELECT name FROM item_tempate WHERE name LIKE '%$search%'") or die(mysql_error()); $num = mysql_num_rows($result); if($result > 0){ while($r=mysql_fetch_array($result)) { $name=$r["name"]; echo "$name<br>"; } }else{ echo 'No matching items found!'; } } ?> You'll notice i've also added something to ensure the query is only perfomed once the search button has been pressed.
  8. You can use AND or you can use &&. Most people would use &&: <?php $foo = 1; $bar = 10; if($foo==1 && $bar < 5){ echo 'result1'; }elseif($foo==1 && $bar > 10){ echo 'result2'; }else{ echo 'result3'; } ?> If you want an if statement to evaluate to true when one of two things are true, use OR (||): <?php $foo = 1; $bar = 2; if($foo==1 || $bar ==1){//note, this will be true when one or both of these statements are true. echo $result1; } ?>
  9. That would be because $title contains the text 'title'. You need to be passing the original title: header( "Location: http://ccgi.xxxxxxx.xxxxxxxxx.co.uk/cgi-bin/thankyou.php?title=".$_REQUEST['title']."&surname=".$_REQUEST['surname']); You may wish to consider validating your data. At present, a malicious user may be able to use your thank you emailer to send spam from your server.
  10. Im assuming you mean H/AB? Either way, thats odd. Perhaps try doing: select *, ROUND((hits/ab),3) as avg...
  11. Printing a page is a job for javascript. Weather or not you can have javascript print a portion of the page i'm not sure. Im not aware of a way, but then im no expert. Perhaps you will need to have the button launch a page containing the information you want printed and print from there.
  12. It appears to work fine for me. In any case, you shouldn't have need to escape the ampersand - it is being used to separate the arguments. What version of PHP are you using?
  13. If there's only two decimal places being shown without you doing anything, then it would suggest that the number can be shown exactly to two decimals - that is, can be written as a fraction with 100 as the denominator. Perhaps you wanted 3 decimals to be shown regardless? So an extra 0 would be shown? If so, you can use the number_format() function: echo number_format($var,3);
  14. Perhaps you're right. I just can't remember the last time i saw a progress bar, microsoft product or otherwise, which seemed to be a true reflection of progress.
  15. That depends on what the field is supposed to contain. If, for example, it was supposed to contain 1 for items that should be checked, and 0 for items which weren't you could do: <?php if($row['ckReceiptIssued'] == 1){ $selected = 'selected="selected"'; }else{ $selected = ''; } echo '<input name="ckReceiptIssued" type="checkbox" '.$selected.' />' ?>
  16. Not true - if you dont specify a value in an insert query, the default will be used. In the case of auto-increment field, that will be next number.
  17. The error actually originates from your second query - the reason why it appears to be from the first is that you have $query in all your error messages, but the query changes from $query to $query2 and then $query3. Hence, if there is an error on $query2, the error message contains $query. You were missing a comma in your second query. Try: $query2 = "INSERT INTO address (address_id,business_id,unit_number,street_number, address, postcode) VALUES ('','$bid','$un','$sn','$ad','$pc')";
  18. If you would like to have a checkbox checked when it loads, you need to set the attribute checked. For example: <input type="checkbox" value="Whatever" checked="checked" />
  19. Make the call to the function directly after the query, and store it in a variable?
  20. Yes, you're right - otherwise the code will create a new row unnecessarily. I also forgot to open the table tag. That makes the code: <table> <?php $query = "SELECT * FROM `property` WHERE `country` = ".$_GET['country']; $result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error()); if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 3; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo "<td>"; ?> <div class="txt_titlesearch"> <img class="dsR13" src="images/property/<?php echo $img01; ?>" alt="" border="0" /><br /> <br /> <?php echo$town; ?></div> <div class="txt_bodysearch"> <p><?php echo $title; ?><br /> <?php echo $price; ?><br /> Projected yield <?php echo $yield; ?></p> </div> <?php echo "</td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>'; } ?> </table>
  21. As for the errors - looks like they're caused becuase you're using a + sign to append the $imgNum onto the end of 'file' rather than a . Perhaps mjdamato was thinking in javascript. Try: <?php $imgTypes = array ( 'image/gif','image/jpeg', 'image/jpg', 'image/png', 'image/tif', 'image/psd', 'image/bmp', 'image/pct', 'image/pjpeg'); for ($imgNum=1; $imgNum<=10; $imgNum++) { $image = $_FILES['file'.$imgNum]; $fileName = $image['name']; $tempName = $image['tmpName']; $fileSize = $image['size']; $fileType = $image['type']; $fileErr = $image['error']; if ($fileErr>0) { echo "Return Code: $fileErr\n"; } else { if (in_array($fileType, $imgTypes) && ($fileSize < 200000000000)) { echo "Upload: $fileName\n"; echo "Type: $fileType\n"; echo "Size: " . ($fileSize / 1024) . " Kb\n"; echo "Temp file: $tempName\n"; if (file_exists("upload/" . $fileName)) { echo "$fileName already exists.\n"; } else { move_uploaded_file($tempName, "upload/" . $fileName); echo "Stored in: " . "upload/" . $fileName; } } else { echo "Invalid file"; } } } ?>
  22. Havn't had time to read the whole thread, but the way you're storing the data in your database is just asking for trouble down the line. You should read up on database normalization. Here would be a good place to start.
  23. So have your accounts require verification by an administator after they are registered but before you can log in with them. It'd be far more user friendly. Really? I can't see any user-input data here: <?php $id = array(array('4471', '1337')); if (in_array(array('4471', '1337'), $id)) { header( 'Location: http://www.flycay.com/caypilot/main.php' ) ; } ?>
  24. Im a bit confused as to why we have a while loop and a do-while loop. However, it should be a simple matter of taking the code from the FAQ/thread i posted above, and putting your query and and data into it: <?php $query = "SELECT * FROM `property` WHERE `country` = ".$_GET['country']; $result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error()); if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 3; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo "<td>"; ?> <div class="txt_titlesearch"> <img class="dsR13" src="images/property/<?php echo $img01; ?>" alt="" border="0" /><br /> <br /> <?php echo$town; ?></div> <div class="txt_bodysearch"> <p><?php echo $title; ?><br /> <?php echo $price; ?><br /> Projected yield <?php echo $yield; ?></p> </div> <?php echo "</td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i < $max_columns) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; } ?> </tr> </table> You might want to try the above on a separate page, to make sure nothing else is interefering. Then put it back in this page to get it working how you want.
×
×
  • 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.