[Solved] How can I avoid SQL injection in my code below? [duplicate]

As suggested, prepared statements are the best way to achieve good protection from SQL injection. Shortened Example You will need to add entries to fill in all columns you wish to insert. $email = $_POST[‘e-mail’]; $fn = $_POST[‘firstname’]; $ln = $_POST[‘lastname’]; if ($stmt = $mysqli->prepare(“INSERT INTO `newcartdb`.`orders`(Email,Firstname,Lastname) values(?,?,?)”) { $stmt->bind_param(“sss”, $email, $fn, $ln); “sss” – … Read more

[Solved] Mysql & PHP Error [closed]

2014-02-18 05:25:38 is a very very specific time to query. You’re only using one of your variables. You probably mean something like this: $from=$_POST[“datefrom”]; $to=$_POST[“dateto”]; SELECT * FROM ss_orders where order_time >= ‘”.$from.”‘ AND order_time <= ‘”.$to.”‘ limit 60 Also, switch to mysqli or PDO and sanitize those inputs. If this is a public form … Read more

[Solved] Checking validity url in php [closed]

I would do the opposite. Instead of removing http:// or https:// and then adding it again, I would just check if the string starts with http:// or https://, and add http:// only if it doesn’t. Something like: if($rr[‘site’]) { $url = preg_match(‘/^https?:\/\//’, $rr[‘site’]) ? $rr[‘site’] : ‘http://’.$rr[‘site’]; echo ‘<a target=”_blank” href=”http://’.$url.'” class=””>’.$url.'</a>’; } 1 solved … Read more

[Solved] The user ID is not defined

You query is returning false on the following line $dn = mysql_query(‘select user_name, user_email from users where user_id=”‘.$id.'”‘); You will need to find out why, you should not attempt anything untill it returns true: $sql = sprintf(“SELECT user_name, user_email FROM users WHERE user_id = %s”, mysql_real_escape_string($id)); $dn = mysql_query($sql); if(!$dn){ echo “mysql_query() failed”; exit(); } … Read more

[Solved] Remove underscore from php echo output [closed]

what madness is this? if($validation->fails()) { echo ‘<div class=”error_message”>’ . str_replace(“_”,” “,($validation->errors()->first(‘first_name’))) . ‘</div>’; } 0 solved Remove underscore from php echo output [closed]

[Solved] Displaying selected dropdown option [closed]

This is a very simple task and you shouldn’t need php or jquery =) Here’s a quick solution that may work for you: HTML: <select> <option value=”foo”>foo</option> <option value=”bar”>bar</option> </select> <div></div> JS: var select = document.querySelector(“select”); var div = document.querySelector(“div”); select.onchange = function(e){ alert(this.value); div.innerText = this.value; }; Example 4 solved Displaying selected dropdown option … Read more

[Solved] Php mysql tabs don’t output [closed]

Use this CSS on your display element: .lineBreaks { white-space: pre-line; } For example in your page: <div style=”white-space:pre-line”> <?php echo $mysqlData ?> </div> 2 solved Php mysql tabs don’t output [closed]

[Solved] Php charset information [duplicate]

Use PHP function utf8_encode Try: <input type=”text” id=”de” value=”<?php echo utf8_encode($row->de); ?>” class=”input” size=”50″/> Make sure that the IDE uses is configured as the default UTF-8. This is spot-checking, ie the entire return must place this function. To correct definitive in check as below: In every PHP output header, specify UTF-8 as the encoding: header(‘Content-Type: … Read more

[Solved] I want to extract a database from a sever using an url using php code [closed]

Use file_get_contents() in php The file_get_contents() reads a file into a string. This function is the preferred way to read the contents of a file into a string. Because it will use memory mapping techniques, if this is supported by the server, to enhance performance. Syntax file_get_contents(path,include_path,context,start,max_length) <?php $data = file_get_contents(“http://www.amazinglaundryservices.com/hybrid_app/staging_webservices/get_location_area.php”); //echo “<pre>”; //print_R(json_decode($data, true)); … Read more

[Solved] Error when writing code php [duplicate]

$_POST has value, after submitting form, so before that anybody can’t use $_POST .. <?php if(isset($_POST[‘title’])){ //Here in condition if(array_key_exists ( ‘title’ , $_POST )) can also be checked… //OR if(!empty($_POST)) OR if(!empty($_POST[‘title’])) can also be put.. $title = strip_tags($_POST[‘title’]); } ?> solved Error when writing code php [duplicate]