Jump to content

WesleyA

Members
  • Posts

    172
  • Joined

  • Last visited

Everything posted by WesleyA

  1. trimming the input first works fine. Thanks for the suggestion Now, I want to use get_headers to test if a website exists. But testing only at status code 200 seems not enough. Sometimes an URL gives code 301 or 302 or so. So how exactly is get_headers used? What is recommended I mean. Is it possible to check all status codes and how is that done?
  2. ok this is the output of an URL giving an error message:
  3. <html><center><br><br><br>checks with get headers <form action="#" method="post"> <input type="text" name="webadres" value=" " required> <br> <input type="submit" value="Send" ><br><br><br> </form> <?php if ($_SERVER['REQUEST_METHOD'] == 'POST'){ $sites= $_POST['webadres']; var_dump($sites); if (isset($sites)) { var_dump(get_headers($sites)); } ?> <br><br>Checks with curl get info <?php $url = curl_init($sites); curl_setopt($url, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($url); $info = curl_getinfo($url); print_r($info); curl_close($url); } ?> </html> I made above script to test whether a webadress exists or not. I'm very surprised that a lot of inputs dont give any result, they actually give a php error message. using sites like http://www.facebook.com does not work, for it twitter it runs. pinterest does only run http and not https. I also found sites like http://www.bbc.co.uk or http://www.cnn.com and more giving no result. Can someone explain why this happens and how to securily check the existance of a website.
  4. OkI think the last option provides me of the output I need but I have a range of names and drinks. What way can it be inserted? Is this correct? $data = array( array( 'name' => '$names','drink' => '$drinks')) or maybe $data[]? .................. This does not work for instance: <?php $naam = array('Mark', 'Lauren', 'Baasgozer'); $drinks = array('cocktail', 'champaign', 'Wodka'); $data = array( array( 'name2' => $naam ,'drink2' => $drinks)); foreach($data as $row) { echo $row['name2'] . ' ' . $row['drink2']; echo '<br>'; } ?>
  5. My goal is to loop with foreach through two variables. So I found this script; <?php $abc = array('Mark','Laura'); $add = array('cocktails','champagne'); $array = array($abc,$add); foreach ($array as list($arr1, $arr2)) { // echo '<br>'; echo '<br>'; echo $arr1; echo '<br>'; echo $arr2; } But the output is not wat is desired. It says: And I would rather have: Is there any function / command in the php array reference to do this or should other code be used?
  6. Hi there I'm looking for a way to strip multiple backslashes. I'm able to strip up to 7 backslashes. This is my code: $url = stripslashes($url); $url = stripslashes($url); $url = stripslashes($url); You read it well, I used it 3 times. I know the backslash is a delimiter so it is necessary to use it 3 times to strip one slash. But my goal is (like with other characters) to strip all. How is PHP handling this?
  7. @ justsomeguy What I want is different. I noticed an important difference between MYSQL punctuation and PHP. Am I right that MYSQL in this way differs from PHP? Why is this? And how should I write the code above in the former posting; in PHP?
  8. I use for instance this in the sql console CREATE TABLE temp SELECT DISTINCT col1, col2, col3, col4, col5 FROM my_table GROUPED BY col1; After that I drop my_table DROP TABLE my_table; then I use ALTER TABLE and RENAME like this ALTER TABLE temp RENAME TO my_table But I need to make a php script of it. so my_table is in my case $var How should the query look like then?
  9. I found different techniques online. One is with SELECT DISTINCT. The result is an output of all unique fields from a specified column . The technique makes you create a new table with only these unique column fields. I would like to use these commands but then without having to make a new table. Maybe I decide to do make it with a new table and then change the new name into the old name. But if there is an easier way I would like to do that. @dsonesuk : I realize now it is not a duplicate record but a duplicate field. I explained that wrong: It's not I want to create a phonebook with only appearing single occurences of 1 family name
  10. like this: unique number ------- column 1----------column 2 ----------- 1 John Doe 2 Mark Holmes 3 Aly Holmes Holmes is then a double input in one column. I would like to use mysql to find these doubles and the delete the entire record.
  11. Hi I'm looking for php/mysql code to find identical input in a mysql database column.
  12. I already had session_start() in the top of the document
  13. I should have posted my own code making it clearer. <form action="#" ><SELECT name="rubsel" class="btn"><?php$tmp=0;while($row = $result->fetch_assoc() ) {$reeks = implode(" " , $row); ?> <optgroup ="btn" label = "<?php echo $reeks; ?>" ><?php echo $reeks ;$tmp ; ?><option class="btn" name="rub_sub1" value="<?php echo $reeks; ?>">1 t/m 10 </option><option class="btn" name="rub_sub2" value="<?php echo $reeks; ?>">11 t/m 20 </option><option class="btn" name="rub_sub3" value="<?php echo $reeks; ?>">21 t/m 30 </option><option class="btn" name="rub_sub4" value="<?php echo $reeks; ?>">31 t/m 40 </option></optgroup><?php $tmp++;}?></SELECT><br><br><input type="submit" class ="btn" name ="tab_wrd" value="Kies Rubriek" /> <br><br></form> name "rub_sub1" is not read and cant be output.
  14. Adding this code doesnt work actually. $_SESSION['sub_seltest1'] = $_GET['sub_seltest1']; var_dump($_SESSION['sub_seltes1']);
  15. This is an example working with optgroup. <form action="#" ><SELECT name="rubsel" class="btn"><?php$tmp=0;while($row = $result->fetch_assoc() ) {$reeks = implode(" " , $row); ?> <optgroup ="btn" label = "<?php echo $reeks; ?>" ><?php echo $reeks ;$tmp ; ?><option class="btn" name="rub_sub1" value="<?php echo $reeks; ?>">1 t/m 10 </option><option class="btn" name="rub_sub2" value="<?php echo $reeks; ?>">11 t/m 20 </option><option class="btn" name="rub_sub3" value="<?php echo $reeks; ?>">21 t/m 30 </option><option class="btn" name="rub_sub4" value="<?php echo $reeks; ?>">31 t/m 40 </option></optgroup><?php $tmp++;}?></SELECT><br><br><input type="submit" class ="btn" name ="tab_wrd" value="Kies Rubriek" /> <br><br></form> What i would like to know is how the input is being processed when using php. Especially how to find exactly the value of <option> The Select name input is found and echoed but what if I put a name attribute in the option element? I cant get an output of that. Or is there another way to get the option value with other attributes for instance?
  16. I dropped a column (linknum) in a table (wine) with mysql in the console After that I wanted to make it again ALTER TABLE wine ADD linknum INT DEFAULT '1' NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST; but now I recieve an error message like this: ERROR 1067 (42000): Invalid default value for 'linknum' How can I solve it, and create a column called linknum again, starting with 1 and incrementing 1 ?
  17. Can you explain what ' id ' is in: DELETE FROM table WHERE id ..... is it something you identify something with or is it an identical unique number? I would like to find a way to match the unique key and use this key to delete the entire record.
  18. Is it possible to use an array, so a range of numbers to delete records from a table? This is the normal query $sql = "DELETE FROM MyGuests WHERE id=3"; But this only deletes one record. I have several numbers and I would like to use an array but I'm not sure whether it is possible or not. Can you just use something like $sql = "DELETE FROM MyGuests WHERE $_GET['id']"; so var_dump($_GET['id']); would be something like: 5, 8, 14, 88 and all these records would be deleted. Like this: array (size=5)0 => string '7' (length=1)1 => string '11' (length=2)2 => string '15' (length=2)3 => string '17' (length=2)4 => string '21' (length=2)
  19. This is my situation If variable $conn has all variables (with a value) $conn = new mysqli($servername, $username, $password, $dbname); and then you use var_dump($conn); and the output would be null of all the values of $conn. What would it mean? Am I right the connection then needs to be re-established? I'm doing 2 queries on a database. First query is SHOW TABLES then make the user choose a table value. From this value a new query is done. So first connection is done. But can I use this connection or should I make a new one?
  20. I found (.*) which works fine. Topic may be closed
  21. I was thinking like any character after the first / is that possible?
  22. There is an issue I have with creating a filter for the correct domain and toplevel domain. For example google.com is correct and all the other not. my code: function my_funct($data2) { $data2 = preg_replace('#(http://www.|http:|https:|ftp://www.|https://www./|//|www.|htp:|htt:|htp:/|htt:/|)# ' , '', $data2); return $data2; } but directories wil not be blocked like www.google.com/directory/page/page2 is there a way to use preg_replace and put only domain and toplevel domain in it? maybe it is possible to negate it, but he entire validation of pre_replace would be changed I assume.
  23. so "any" automatically lapses if you create a user with password? Or do I have to change more settings to keep unwanted people out?
  24. I have a question about security and MYSQL. I installed MYSQL and PHPMYADMIN. I changed the root password. But when in PHPMYADMIN I see a list of users and priviliges. Usernames sound like: All, root or pma. I understand I need pma or root, but what is the use of All ? User name Host Password Global privileges User group Grant Action Any % -- USAGE Any localhost No USAGE pma localhost Yes USAGE root 127.0.0.1 Yes ALL PRIVILEGES root ::1 Yes ALL PRIVILEGES root localhost Yes ALL PRIVILEGES Furthermore which priviliges and global rights should a user have when developing localhost?
  25. Yes I think it is not possible to secure something a 100%. But why not try to get as close as possible. But security is now not yet the issue for me as validating is more then just having crappy code in your database. An empty record is also useless even if it is done by accident. I found some code I changed: <?php $string = "namename"; $newstring = str_replace("name", "Foo", $string, $count); print "$count changes were made.n"; if ($count>1) { echo "<br> ". $newstring;} ?> But the problem is that if you make a string like this; <?php $string = "Hey name you can type your name in this field. Bye name"; $newstring = str_replace("name", "", $string, $count); print "$count changes were made.n"; if ($count>1) { echo "<br> ". $newstring;} ?> This causes the wrong output and I want to have the correct one, is there a solution?
×
×
  • Create New...