arunpatal
-
Posts
273 -
Joined
-
Last visited
Posts posted by arunpatal
-
-
Hi,
Have a look this menu
I want the same mune but with click function (its using hover function now)
Please help me with this
-
Because you are using single quotes for denoting the textarea id. Change your single quotes to double quotes instead
$string = ""; $string .= "<textarea id=\"convert\"> 'AA' </textarea>"; $string .= "<textarea id=\"convert\"> 'BB' </textarea>"; $string .= "<textarea id=\"not_convert\"> 'CC' </textarea>"; $string .= "<textarea id=\"not_convert\"> 'DD' </textarea>";
Thanks.. its working
-
After you have defined the $string variable.
$string = ""; $string .= "<textarea id='convert'> 'AA' </textarea>"; $string .= "<textarea id='convert'> 'BB' </textarea>"; $string .= "<textarea id='not_convert'> 'CC' </textarea>"; $string .= "<textarea id='not_convert'> 'DD' </textarea>"; $string = preg_replace_callback('/(<textarea id="convert">)(.*?)(<\/textarea>)/is' ,function($m) { array_shift($m); $m[1] = str_replace('AA', 'ZZ', $m[1]); return implode($m); } ,$string); echo $string;
I tried this way but its not working....
-
Could try this if your using PHP 5.3.0 or newer
$string = preg_replace_callback('/(<textarea id="convert">)(.*?)(<\/textarea>)/is' ,function($m) { array_shift($m); $m[1] = str_replace('AA', 'ZZ', $m[1]); return implode($m); } ,$string); echo $string;
Sorry but how do i implement this code with the above code i wrote?
-
If the textareas always look the same, you could use str_replace():
str_replace() will not solve the problem...
i can change textarea a bit if its requeired but lets say if string is like this and i want to change all AA to ZZ
<?php $string = ""; $string .= '<textarea id="convert"> "AA" KAA="AA" $AA</textarea>'; $string .= "<textarea id='convert'> 'BB' </textarea>"; $string .= "<textarea id='not_convert'> 'AA' </textarea>"; $string .= "<textarea id='not_convert'> 'DD' </textarea>"; ?>
-
Hello everyone,
example string
<?php $string = ""; $string .= "<textarea id='convert'> 'AA' </textarea>"; $string .= "<textarea id='convert'> 'BB' </textarea>"; $string .= "<textarea id='not_convert'> 'AA' </textarea>"; $string .= "<textarea id='not_convert'> 'DD' </textarea>"; ?>
I want to change 'AA' to 'ZZ' which is inside textarea with the id convert only.
How is it possible with the help of regular expression?
-
<script>alert("hack")</script> is a test for reflected cross site scripting (XSS) not for SQL injections
So should i use htmlspecialchars function to skip script tags??
-
Hi,
i was testing this example
<?php $con = mysqli_connect("localhost","test","","test"); if(isset($_POST["name"])): $stmt = $con->prepare("INSERT INTO products (name,price) VALUES (?,?)"); $stmt->bind_param('si', $name, $price); $name = $_POST["name"]; $price = $_POST["price"]; $stmt->execute(); echo "Inserted {$name},{$price} into database\n";; endif; ?> <form method="post"> <input type="text" name="name" /> <input type="number" name="price" /> <input type="submit" /> </form>
But when i write
<script>alert("hack")</script>
into name input field then the code execute..........
What am i doing wrong???
-
Hi,
I use mysql_escape_string to insert data into my database......
example: $name = mysql_escape_string($_POST["name"]); $lname = mysql_escape_string($_POST["lname"]);
mysql_query(INSERT INTO table (fname,lname) VALUES ('$fname','$lname'));
But i am not sure if this is safe enough to protect from mysql injuction....
My question is if it's safe to insert data like this?????
-
Hi,
I have a variable $last_visited_time contain time. example 15:12:45
i want to add 30min extra to this time variable....
how can i do this???
-
if you are using the mysqli_query() function, you MUST use the corresponding mysqli_fetch_xxxxx() functions. you cannot mix mysqli and mysql (no i) functions.
That was it..... thanks a lot
-
$ip_list_to_check = $viks2007->sql_count("SELECT user_ip,DATE_FORMAT(date_time,'%H:%i:%s') AS date_time FROM $count_table_name"); while($row = mysql_fetch_array($ip_list_to_check)): //save all ipaddress in ip_list_array array $ip_list_array[] = $row["user_ip"]; //save all time in time_list_array array $time_list_array[] = $row["date_time"]; endwhile;
This is function in viks2007 class
function sql_count($sql){ $query = mysqli_query($this->connect,$sql); return $query; }
Am getting error
Warning: mysql_fetch_array() expects parameter 1 to be resource, object given in C:\xampp\htdocs\includes\ip_address.php on line 8
-
Adding ob_start(); solved the problem
-
== is not a problem.....
mac_gyver
can you tell me the solution for this problem........
by giving example with the code above... Please
-
<script> function check_field(){ document.getElementById("guest_form").submit() } </script> <?php if (isset($_POST["name"]) AND $_POST["name"] = "name"){ header("location:page.php"); } ?> <form method="post" id="guest_form"> <input type="text" value="abc" name="name" /> <input type="button" value="Sub" onclick="check_field()" id="aa" /> </form>
When am running this code on my pc (xampp), It is running fine.
But when i upload the file on server (godaddy).....
it does not redirect....... or the header is not working
-
Great example... Thanks
-
Hi,
I have two date and title fields
<input type="text" name="event_name" placeholder="Starting Date"> <input type="text" name="from" placeholder="Starting Date"> <input type="text" name="till" placeholder="Ending Date">
I have a table call events....
id - auto inc
title - varchar(45)
date - date
__________________________________________________________
now for example starting date is 2014-04-25 and ending date is 2014-05-09
I want to save all these date with their event name to events table....
example
id date event
1 2014-04-25 event_name
2 2014-04-26 event_name
3 2014-04-27 event_name
4 2014-04-28 event_name
....................................
what would be the way to store????
-
If you are extracting month from date('m') it's never going to be greater than 12?
I have a calander which i make start like this date('m')...
now, i want to add 2 years calander(24 month from current month) for which i make date('m') + 1 ..... date('m') + 23...
that is why the month is going 13,14,15......
-
I will try it and will get back to it....
thanks for example
Are you just trying to return $month plus 1 and if $month is 13 it becomes 1?
$month = date('m'); function month($month){ $month = ++$month; if($month >12)$month = 1; return $month; } echo month($month);
after 12 it display all month as 1
if($month >12)$month = 1;
i need to make a loop...
somthing like this
if month is 13 then it start from 1 again till 12
and when month is 25 then again 1 till 12... and so on
-
Are you just trying to return $month plus 1 and if $month is 13 it becomes 1?
$month = date('m'); function month($month){ $month = ++$month; if($month >12)$month = 1; return $month; } echo month($month);
I will try it and will get back to it....
thanks for example
-
Hi,
This is month (example november)
$month = date('m');
This is month + 1 (example december)
$month = date('m') + 1;
Now adding + 2 shows 13
$month = date('m') + 2;
This is orignal code
if($month == 13): $month = sprintf("%02s", 1); $year++; endif;
It make 13 into 1 but then it repeats again from 14
13 becomes 1
then 14 stays 14
how can i make month start from 1 till 12 with the help of loop....
ofcourse one bad solution is that i doi it with if statement like
if ($month == 14){$month = 2} if ($month == 15){$month = 3}
Is there a way to do it via loop ???
-
Hi,
The code below work fine when i want to change the value of background-color property
<script> $(document).ready(function(){ $(".img_div").click(function(){ var element_value = $(this).val(); $("#main_div").css({"background-color":element_value}); }); }); </script>
But when i want to change property itself (background-color), its not working
<script> $(document).ready(function(){ $(".img_div").click(function(){ var element_prop = $(this).val(); $("#main_div").css({element_prop:"black"}); }); }); </script>
-
Ok the problem was solved like this
$add_gallery = array_filter($_FILES["gallery"]["name"]); if(!empty($add_gallery)) { code } else { };
-
Hi,
I am uploading multiple files
<form enctype="multipart/form-data" method="post"> <input type="file" name="gallery[]" multiple="multiple" /> <input type="submit" value="Update" name="gallery_submit" /> </form>
But if not empty statement is not working with it
if (!empty($_FILES["gallery"]["name"])){ $mysql->upload_gallery_img($gallery1); }
I want that when file is selected then only the upload_gallery_img function runs
regular expression pattern
in PHP Coding Help
Posted · Edited by arunpatal
Hello,
I have a file to display
This file is encoded....
In this file there is a specific tag call change_me
I want to use htmlspecialchars_decode function for <change_me> tag only...
<change_me> tag is used two times in file.
Thanks