Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. Thats true. But in that case, he should just use html entities, as there are quite a few html tags that support the onclick event. He could also do a regex replace to get rid of all onclick events also, if he really wanted to use strip_tags. However as jcbones has said, using bbc code is probably the best option.
  2. You may have a mysql error. to debug, you could change this line $query_result = mysql_query($query); to $query_result = mysql_query($query) or die(mysql_error()) ' Note, that using or die() is not a good idea in production, but is fine while you are working out the bugs. A couple things I noticed. One of your column names is desc. This is a reserved word in Mysql, so if you want to use it, you need to surround it with backticks (`). The better option would probably be to change the column name but thats up to you. This line $query = "SELECT * FROM table1 WHERE desc LIKE '$arraySearch'"; and specifically the part where you do LIKE '$arraySearch'"; doesn't quite make sense. $arraySearch is an array, and when you use it like that in a string, the whole array gets cast as a string. Arrays being cast as strings result in the string "Array", so for example, if I had some array, $array (doesn't matter whats in it) and I did echo "Array to string conversion: ".$array the result would be Array to string conversion: Array It may also help if you echo the whole query, and post it here. just add echo $query; after your loop that builds it. Once you report the mysql error and the query you are trying to run we can be of more help
  3. In addition to htmlentities, if you simply wanted to remove certain tags from the users input, you could use the strip_tags() function using the optional allowable tags argument, if you wanted to remove every tags but, for example, anchor tags.
  4. a URL is basically an address you give to a browser to get to a webpage. IE, http://www.example.com/page.php. Basically, you can't use the http protocol to get to a file to unlink. As PF said, if you could, someone would just continually delete everyones files. This would be pretty funny admittedly, but not good for the internet. A system path can be two things, absolute, or relative. Relative is the path from the script you are running to the file you want to access (for deletion, changing, writing, whatever) Absolute is the absolute path to the file. For example, if I have the following folder structure C: --folder1 --folder2 file.php --folder3 file_for_deletion.jpg and my delete script is in file.php, the relative path would be "folder3/file_for_deletion.jpg", and the absolute path would be C:/folder1/folder2/folder3/file_for_deletion.jpg. hope this helps
  5. Oh yes, thank you for pointing this out.
  6. I think you expect that php if statement to restrict the rows where your expired flag is set to yes, but in reality, all that will happen is every single row where expired is "N"is set to "Y", which basically sets all your rows to "Y" expired. If you have a unique or primary ID column, you could use that in your where clause also, something like mysql_query("UPDATE Autos SET Expired = 'Y' WHERE Expired == 'N' AND id={$row['id']}"); assuming that the column was called id, but this way is somewhat inefficient. You could accomplish what you want to do (basically flagging old entries in the table) with a single update query. see the date and time functions mysql has built in. Note, these only work on the date/time column types, which I am assuming you are using
  7. is this code returning a mysql error? what exactly happens when you run this?
  8. well since he's trying to see if a set of array keys exists in an array, he'd probably need to use array_diff in combination with array keys. like $subjectArray = array("array we are looking through", ...); $searchKeys = array ("keys you are looking for", ...); $result = array_diff($searchKeys, array_keys($subjectArray)); if (empty($result)){ //all the keys in searchKeys are defined in the subjectArray }
  9. I'm pretty positive no such function exists, but as you said, using the built in array_key_exists() function iteratively or recursively would be easy enough to do what you want
  10. I'm not sure if it would be possible to select the IDS in descending order, then reorder them in ascending order with just MySQL. If there is, I do not know the function or language construct that can do it. But MySQL isn't my strong point, so another poster more experienced in SQL may be able to give better advice
  11. you get the very first 16 because you order by the id in ascending order. You could order by descending order to get the most previous 16
  12. well it would help if you provided the query you are using also, but I will assume you are using a select statement. With select statements, the result resource that is obtained from doing mysql_query will coerce to true unless there was a mysql error (even if there are no rows returned). You basically want to check if there were any rows returned. You can use mysql_num_rows to check how many rows were returned from your query. for example $rs = mysql_query($sql,$dbc); $num = mysql_num_rows($rs); if (!$num) { echo "You aren't scheduled to work in the next seven days...but check back often as the schedule is adjusted often."; } $matches = $num;//no need for a while loop
  13. well, assuming you don't want to use the common pagination technique described in the tutorial linked in the first reply, what exactly is the problem? what happens when you click the next/previous button, and what do you expect to happen? Saying it "bugs out" isn't a sufficient description of the problem
  14. are you sure $rowinformation is an array? Try using print_r on the $_SESSION super global, and make sure it has what you expect it to have in it
  15. jesus, your variable names are ridiculous. but yeah, look into the DATE_FORMAT() mysql function.
  16. Improve it in what way exactly? You should provide more details on HOW exactly you want to improve something before asking for advice. Not only does it get you thinking about your code, but it is easier for others to help you as well. A few things I noticed, you don't check if the form was actually sent on your form action page. You can do this by checking of the submit button has a value. Your submit button currently has no name, so you should change ur submit button to something like <input type="submit" value=" Submit Form " name="mySubmitButton" /> and then on your action page, check if it is set, using isset() if (isset($_POST['mySubmitButton'])){ $email = $_POST['email']; $message = $_REQUEST['message']; $message = $_POST['date']; $message .= $_POST['location']; $message .= $_POST['comments']; mail( "testing@gmail.com, 5602346789@metropcs.com", "General Inquiry", $message, "From: $email" ); header( "Location: thankyou.html" ); } otherwise, someone could navigate to this page, and keep refreshing it, which would send a bunch of empty emails. You never sanitize or validate any of your $_POST variables either, which could lead to being sent unexpected data in your emails, or even spam. There are some more advanced topics I could cover, but this should get you started
  17. you forgot the second isset function if(!isset($_GET['get']) || !isset($_GET['getget'])){ perhaps that is what you are after? EDIT: althought, if you want to have an error if neither are set, you want to use AND, not OR. IE if(!isset($_GET['get']) && !isset($_GET['getget'])){ otherwise it will redirect if either is unset. if this functionality is what you are after, leave it as OR
  18. do you have a column in your table that is a timestamp of when the row was entered? if so is it a date or datetime type?
  19. it allows you to do things like formatting the date how you want inside the query so you don't have to worry about doing it in the PHP. It also makes date based math much easier to process. Among many other things. For your example, had you used a date or datetime column type, you could have just used the date function format_date (i believe thats the name, don't quote me on it)
  20. while a numerical reference to a column in an update statement seems to be impossible, why don't you use arrays and a foreach loop to generate your list of columns to update for you
  21. what is wrong with what you posted? What is happening when you try to run that code?
  22. oh. why don't you just use strtolower on the hashed string then? does that not work? you could also use strcasecmp().
  23. oh, i didn't notice this, but you arent selecting photo_category in your sql select statement. perhaps this $result = mysql_query( "SELECT category_id,category_name FROM gallery_category" ); should be $result = mysql_query( "SELECT category_id,category_name,photo_category FROM gallery_category" ); I'm not entirely sure where the photo_category column resides though, so I'm more or less taking shots in the dark
  24. well in this code <? $result = mysql_query( "SELECT category_id,category_name FROM gallery_category" ); echo "<select name='photo_category' size='1'>"; while( $row = mysql_fetch_array( $result ) ){ //echo "<option value=\"".$row['photo_category']."\">".$row['category_name']."</option>"; echo "<option value=\"$photo_category\">".$row['category_name']."</option>"; } echo "</select>"; ?> You never define $photo_category from what I can see. Perhaps you should do <? $result = mysql_query( "SELECT category_id,category_name FROM gallery_category" ); echo "<select name='photo_category' size='1'>"; while( $row = mysql_fetch_array( $result ) ){ //echo "<option value=\"".$row['photo_category']."\">".$row['category_name']."</option>"; $photo_category = $row['photo_category']; echo "<option value=\"$photo_category\">".$row['category_name']."</option>"; } echo "</select>"; ?>
  25. Read the manual and lurk these forums. Tutorials also help a lot, and of course practice practice practice. Regex is shorthand for regular expressions. It is sort of an advanced topic, but do a google search for regular expressions if you wish to find out more
×
×
  • 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.