divyakrishnan 20 Junior Poster
divyakrishnan 20 Junior Poster

Hi All,

I am using php to create a Webservice API calls.
I am checking all the service calls in Chrome's Postman and sending the data in JSON format.
I want to upload an image in JSON format with other datas.Actually I have converted the image to base64 before uploading.Its working fine.But I have found in some posts , there may be a chance of data loss if we upload High definition images.

I want to know that is there any other way to upload images as JSON in postman.

divyakrishnan 20 Junior Poster

Hai Everyone..

Could someone please tell me that is there any jquery plugin to upload an image with editing functionality like resize,drag position as in shown Facebook profile picture upload?

divyakrishnan 20 Junior Poster

Hi..
I setting start date and end date in my php page using javascript with following options.

Start date options

mindate-today
maxdate-end date(after selecting end date)

End date options

min date - start date

Its working correctly.But I want to change the date format from yy-mm-dd to dd-mm-yy.
I changed it using

    dateFormat: 'yy-mm-dd',

to

    dateFormat: 'dd-mm-yy',

That time the mindate & maxdate options are not working.

This is my code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<?php /*?><script src="jquery.js"></script>
<script src="jquery-ui.js"></script>
<link rel="stylesheet" href="jquery-ui.css" /><?php */?>
<script language="javascript" type="text/javascript">

$(document).ready(function() {
    activateDatePickers();
});

function activateDatePickers() {

    $("#promo_start_date").val('');
    $("#promo_end_date").val('');

    $("#promo_start_date").datepicker({
        changeYear: true,
        minDate: '0',
        dateFormat: 'yy-mm-dd',
        onSelect: function() {
            $("#promo_end_date").datepicker(
                    "change",
                    { minDate: new Date($('#promo_start_date').val()) }
            );
            //$("#btnClear").show();
        }
    });
    $("#promo_end_date").datepicker({
        changeYear: true,
        dateFormat: 'yy-mm-dd',
        onSelect: function() {
            $("#promo_start_date").datepicker(
                    "change",
                    { maxDate: new Date($('#promo_end_date').val()) }
            );
            //$("#btnClear").show();
        }
    });

}

</script>

</head>

<body>
          <form class="form-horizontal" role="form" name="add_promo" id="add_promo" action=""  method="post" autocomplete="off">

            <div class="form-group">
              <label class="control-label col-sm-2" for="email">Start Date *</label>
              <div class="col-sm-7">
                <input type="text" class="form-control" id="promo_start_date" name="promo_start_date" placeholder="Select Start Date">
              </div>
            </div>
            <div class="form-group">
              <label class="control-label col-sm-2" for="address">End Date *</label>
              <div class="col-sm-7">
               <input type="text" class="form-control" id="promo_end_date" name="promo_end_date" placeholder="Select End Date">
              </div>
            </div>

            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary" name="promo_submit">Submit</button>
                <button type="reset" class="btn btn-default">Clear</button>
              </div>
            </div>
          </form>

</body>
</html>
divyakrishnan 20 Junior Poster

Thanks for the reply.

Please tell me how I can create multiple displays on my sample code?

divyakrishnan 20 Junior Poster

Hi..
I am using Google map to show the route path between the longitude and latitude points.
Here the default stroke color of the route path is blue.
I want to set it into different colors.
That is,from point A to B is reb,B to C is green,C to D is black like that.

I am Using following code to show the route path.

<script src="http://maps.googleapis.com/maps/api/js"></script>
<script type="text/javascript">
var geocoder;


var marker;
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
var from = "";
function initialize() 
{   directionsDisplay = new google.maps.DirectionsRenderer({
    preserveViewport: true
  });
    /*center*/  
    var latlng = new google.maps.LatLng(13.284198157123711, 80.25910379882816);
    //var lat_lng = new Array();
    var myOptions = {
      zoom: 11,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map"), myOptions);
  directionsDisplay.setMap(map);

    //var rendererOptions = { map: map };
    // directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);

var locations = [
      [ 13.284198157123711, 80.25910379882816],
      [ 13.181262431729227, 80.27421000000004],
      [ 13.037481060623552, 80.15061380859379],
      [12.923064986866681, 80.11490824218754]

    ];

    var point1 = new google.maps.LatLng(13.284198157123711,80.25910379882816);
    var point2 = new google.maps.LatLng(13.181262431729227,80.27421000000004);
    var point3 = new google.maps.LatLng(13.037481060623552,80.15061380859379);
    var point4 = new google.maps.LatLng(12.923064986866681,80.11490824218754);

    // Setup the different icons and shadows
    var iconURLPrefix = 'http://maps.google.com/mapfiles/ms/icons/';

    var icons = [
      iconURLPrefix + 'red-dot.png',
      iconURLPrefix + 'green-dot.png',
      iconURLPrefix + 'blue-dot.png',
      iconURLPrefix + 'orange-dot.png',
      iconURLPrefix + 'purple-dot.png',
      iconURLPrefix + 'pink-dot.png',      
      iconURLPrefix + 'yellow-dot.png'
    ];

    var iconsLength = icons.length;
    var markers = new Array();
    var iconCounter = 0;

    // Add the markers and infowindows to the map
    for (var i = 0; i < locations.length; i++) {  
      var …
divyakrishnan 20 Junior Poster

If we select unallowed file type of more than one file it won't works

divyakrishnan 20 Junior Poster

Hi..

I want to reset the multiple file input field.
Actually my file input field is an array.

I used the following code and it works if the input field is not an array.

<script>
$(function() 
{
$('input[type=file]').change(function () 
    {
    var regex = new RegExp("(.*?)\.(jpg|jpeg|png|pdf)$");
    var f           =   this.files[0];
    $.each(this.files, function (index, file) 
    {
       fileName = file.name;

       fileName =fileName.toLowerCase();

        if(!(regex.test(fileName))) 
        {
            $(this).val('');

            alert('JPG/PNG/PDF files Only');
         }


        });

});
</script>     

     <form>
     <input type=file style="width:100%" id='filename' name='filename[]' multiple="multiple"  />
     </form>

Please help me to find a solution for this.

divyakrishnan 20 Junior Poster

I am using uploadify to upload images in php.
After uploading the files, showing the progress bar as completed but the uploads folder is showing as empty.
I have downloaded the script and just added a new folder to upload files as uploads folder.

Here is my code

index.php

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>UploadiFive Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="jquery.uploadify.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="uploadify.css">
<style type="text/css">
body {
    font: 13px Arial, Helvetica, Sans-serif;
}
</style>
</head>

<body>
    <h1>Uploadify Demo</h1>
    <form>
        <div id="queue"></div>
        <input id="file_upload" name="file_upload" type="file" multiple>
    </form>

    <script type="text/javascript">
        <?php $timestamp = time();?>
        $(function() {
            $('#file_upload').uploadify({
                'formData'     : {
                    'timestamp' : '<?php echo $timestamp;?>',
                    'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
                },
                'swf'      : 'uploadify.swf',
                'uploader' : 'uploadify.php'
            });
        });
    </script>
</body>
</html>

uploadify.php

<?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/

// Define a destination
$targetFolder = '/uploads'; // Relative to the root

$verifyToken = md5('unique_salt' . $_POST['timestamp']);

if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
    $targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];

    // Validate the file type
    $fileTypes = array('jpg','jpeg','gif','png'); // File extensions
    $fileParts = pathinfo($_FILES['Filedata']['name']);

    if (in_array($fileParts['extension'],$fileTypes)) {
        move_uploaded_file($tempFile,$targetFile);
        echo '1';
    } else {
        echo 'Invalid file type.';
    }
}
?>

Please help me to find a solution for this.

divyakrishnan 20 Junior Poster

Thank u very much.
Now its working..

divyakrishnan 20 Junior Poster

Hi ,
I am using following script to get the values of the language details.

<FORM action="final.php" method="post">
<div align="center">
  <table width="434" border="0">
    <tr>
      <td>Languages Known</td>
      <td>Speak</td>
      <td>Read</td>
      <td>Write</td>
      <td>Delete</td>
      </tr>
    <tr>
      <td>
        <select name="lang[]" id="select">
          <option value="">-Select-</option>
          <option value=1>Hindi</option>
          <option value=2>English</option>
          <option value=3>Tamil</option>
          <option value=4>Telugu</option>
          <option value=5>Kannada</option>

        </select></td>
      <td><input name="speak[]" type="checkbox" value="yes" /></td>
      <td><input name="read[]" type="checkbox" value="yes" /></td>
      <td><input name="write[]" type="checkbox" value="yes" /></td>
      <td><input type="button" name="button" id="button" value="Delete" onclick="delete(this)" /></td>
      </tr>
    <tr>
      <td>
        <select name="lang[]" id="select">
          <option value="">-Select-</option>
          <option value=1>Hindi</option>
          <option value=2>English</option>
          <option value=3>Tamil</option>
          <option value=4>Telugu</option>
          <option value=5>Kannada</option>

        </select></td>
      <td><input name="speak[]" type="checkbox" value="yes" /></td>
      <td><input name="read[]" type="checkbox" value="yes" /></td>
      <td><input name="write[]" type="checkbox" value="yes" /></td>
      <td><input type="button" name="button2" id="button2" value="Delete" onclick="delete(this)" /></td>
      </tr>
    <tr>
      <td>
        <select name="lang[]" id="select">
          <option value="">-Select-</option>
          <option value=1>Hindi</option>
          <option value=2>English</option>
          <option value=3>Tamil</option>
          <option value=4>Telugu</option>
          <option value=5>Kannada</option>

        </select></td>
      <td><input name="speak[]" type="checkbox" value="yes" /></td>
      <td><input name="read[]" type="checkbox" value="yes" /></td>
      <td><input name="write[]" type="checkbox" value="yes" /></td>
      <td><input type="button" name="button3" id="button3" value="Delete" onclick="delete(this)" /></td>
      </tr>
    <tr>
      <td>
        <select name="lang[]" id="select">
          <option value="">-Select-</option>
          <option value=1>Hindi</option>
          <option value=2>English</option>
          <option value=3>Tamil</option>
          <option value=4>Telugu</option>
          <option value=5>Kannada</option>

        </select></td>
      <td><input name="speak[]" type="checkbox" value="yes" /></td>
      <td><input name="read[]" type="checkbox" value="yes" /></td>
      <td><input name="write[]" type="checkbox" value="yes" /></td>
      <td><input type="button" name="button4" id="button4" value="Delete" onclick="delete(this)" /></td>
      </tr>
    <tr>
      <td>
        <select name="lang[]" id="select">
          <option value="">-Select-</option>
          <option value=1>Hindi</option>
          <option value=2>English</option>
          <option value=3>Tamil</option>
          <option value=4>Telugu</option>
          <option value=5>Kannada</option>

        </select></td>
      <td><input name="speak[]" type="checkbox" value="yes" /></td>
      <td><input name="read[]" type="checkbox" value="yes" /></td>
      <td><input name="write[]" type="checkbox" value="yes" /></td>
      <td><input type="button" name="button5" id="button5" value="Delete" onclick="delete(this)" /></td>
      </tr>
  </table>

</div>
<div align="center">
  <input name="s" type="submit" />
</div>
</FORM>
</body>

I …

divyakrishnan 20 Junior Poster

Hi
I have added a custom form validation in codeigniter.
The callback function returns true/false & the value of validating field.

// JavaScript Document
class Test extends CI_Controller 
{

/*custom validation function*/
  function _checkdate()
  { 
      $post     =   $this->session->userdata('post');
      echo $fdate   =   $post['frmDt'];
      if (preg_match('/^[0-9-: ]*$/', $fdate)) 
      {
          return true;
      }
      else
      {
          return false;

      }

    }

    function submitform()
    {
            if($this->form_validation->run() == FALSE)
            { 
                        echo "Validation Failed";
                        exit;

            }
    }
}
divyakrishnan 20 Junior Poster

Thank you very much
I have changed my script as

    <?php
    include("dbcon.php");
    $countryname="india";
    $rs1 = mysql_query( "CALL countCountry('$countryname', @totalcount)" );
    //$rs = mysql_query( 'SELECT @totalcount as totalcount' );
    $rs = mysql_query( 'SELECT @totalcount as totalcount' ) or die(mysql_error());
    while($row = mysql_fetch_array($rs))
    {
    echo $row['totalcount'];
    }
    ?>

Now its working.

divyakrishnan 20 Junior Poster

Getting NULL values like

Array ( [0] => [@totalcount] => )

divyakrishnan 20 Junior Poster

Sorry ,its for debugging purpose I fetched twice.

I changed my script as follows

<?php
include("dbcon.php");
$countryname="india";

  $rs1 = mysql_query( 'CALL countCountry($countryname,@totalcount)' );
      //$rs = mysql_query( 'SELECT @totalcount as totalcount' );
      $rs = mysql_query( 'SELECT @totalcount' ) or die(mysql_error());
      while($row = mysql_fetch_array($rs))
      {

      echo $row['totalcount'];
      }
 ?>

Getting a notice like

Notice: Undefined index: totalcount in C:\xampp\htdocs\php\sp\example.php on line 9

divyakrishnan 20 Junior Poster

Hi..
I want to call mysql Stored procedure with OUT parameter.
Its worked in phpamyadmin
But in php it returning empty result.
I have used the following php script.
Can anyone help me?

<?php
include("dbcon.php");
$countryname="india";

  $rs1 = mysql_query( 'CALL countCountry($countryname,@totalcount)' );
      $rs = mysql_query( 'SELECT @totalcount as totalcount' );
      $row = mysql_fetch_array($rs);

      var_dump($rs);

      while($row = mysql_fetch_array($rs))
      {

      echo $row['totalcount'];
      }
 ?>
divyakrishnan 20 Junior Poster

Hi
I want to assign a smarty array to Javascript array
I used the following code

<script type="text/javascript">

var arr = {/literal}{$a.ins_status|@json_encode}{literal}; 
alert(arr);

</script>

But the arrray is showing as Null

divyakrishnan 20 Junior Poster

Hi
How to get the Id of an element after firing the event from another element which is located before first element.
Actually I have dynamically created <select> and a <span>.
I want to get the id of the <span>,after the onchange event of the <select>
Span is located after the <select>
I have used following code

$( this ).after( $( "span" ) ).id;
divyakrishnan 20 Junior Poster

We are working for android and iPhone app basically, so need to test the performance and load capabilities. We tried Jmeter using proxy server in android mobile, but getting error "Authentication via proxy server was unsuccessfull". Can u suggest some open source tool for the same.

divyakrishnan 20 Junior Poster

Actually I want to do a print page.
In which I want to place a logo(jpg file).
This logo is visible in firefox ,but it is not visible in chrome.

divyakrishnan 20 Junior Poster

Hi....
Anyone have the idea about Load Testing Tool for Mobile APPS?

divyakrishnan 20 Junior Poster

Hi..
I want to open an existing popup and append the content to the pop up.
I have used the following code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
function disimage()
{
    var WindowObject = window.open('p1.html', "PrintWindow", "width=750,height=650,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes");

            WindowObject.document.getElementById("d1").innerHTML="Append TEXT";
            WindowObject.focus();
            WindowObject.print();
            //WindowObject.close();

}

 </script>  

</head>

<body>
<input type="button" onclick="disimage()"/>
</body>
</html>

p1.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
Welcome !!!!!!!!
<img src='new_logo.png'>

<div id="d1">
div text
</div>
</body>
</html>

Its not working for me

divyakrishnan 20 Junior Poster

try this

<?php
$string = <<<XML
<a>
<b>
<c>text</c>
<c>stuff</c>
</b>
<d>
<c>code</c>
</d>
</a>
XML;
$xml = new SimpleXMLElement($string);
 $xml->asXML()."<br>";


    //echo "<c>".(string)$child."</c>";
    foreach( $xml->children() AS $child )
{
    //run any query you want on the children.. they are also nodes.
   $name1 = $child;
   //echo "<pre><c></pre>".$name1."<pre><c></pre><br>";
   foreach( $name1->children() AS $child1 )
{
     $name2 = $child1->getName();
     $child2=$child1;
    // echo $name2."--".$child2;
    if($child2=="code")
    {
        echo "&lt;".$name2."&gt;".$child2."&lt;&frasl;".$name2."&gt;"."<br>";
    }

}

}
divyakrishnan 20 Junior Poster

Refer Click Here
for array sorting .
Use a for loop to iterate the array elements and create hexadecimal color value for display.

divyakrishnan 20 Junior Poster

Try this

<?php
$string = <<<XML
<a>
<b>
<c>text</c>
<c>stuff</c>
</b>
<d>
<c>code</c>
</d>
</a>
XML;
$xml = new SimpleXMLElement($string);
 $xml->asXML()."<br>";


    //echo "<c>".(string)$child."</c>";
    foreach( $xml->children() AS $child )
{
    //run any query you want on the children.. they are also nodes.
   $name1 = $child;
   //echo "<pre><c></pre>".$name1."<pre><c></pre><br>";
   foreach( $name1->children() AS $child1 )
{
     $name2 = $child1->getName();
     $child2=$child1;
    // echo $name2."--".$child2;
        echo "&lt;".$name2."&gt;".$child2."&lt;&frasl;".$name2."&gt;"."<br>";

}

}

?>
divyakrishnan 20 Junior Poster

Checkout the form.php Page.
Line no 20 should be

if(document.frm.userNameTxt.value=='')

Like that you have check for every if condition.It should be like
document.formname.fieldname.value

id attribute for all input fields are missing.
Replace like this.

<input type="text" value="" name ="nameTxt" id="name" />
divyakrishnan 20 Junior Poster

I tried following code

function form_image1()
{   

    var uploadedFile = document.getElementById('f1');
    var fileHeight = uploadedFile.files[0].height;
    alert("fileHeight="+fileHeight);
}

Its getting output as "undefined "

divyakrishnan 20 Junior Poster

I want to get the width and height of an image before uploading using javascript.
I used The code shown below.
But its returning 0 value

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
function form_image()
{   

var v=new Image();
v.src=document.getElementById("f1").getAttribute('src');
alert(v.height+"-"+v.width);
}
</script>
</head>

<body>



<form method="post" enctype="multipart/form-data">
<input type="file" id="f1" name="f1" onchange="form_image()"/>
<input  type="submit" />
</form>
</body>
</html>
divyakrishnan 20 Junior Poster

Hi,
I want to get current position of cursor in a text box using asp.net.
Its very urgent for me.
any one can help me?

divyakrishnan 20 Junior Poster

Hi..

I am trying to download a file using FTP Server .
fI used the ollowing script for file downloading.
FTP connection is success.
But while calling ftp_get() Getting an error like

Warning: ftp_get() [function.ftp-get]: File not found in C:\xampp\htdocs\test\ftp_check2.php on line 4

<?php
$conn = ftp_connect("192.168.1.20") or die("Could not connect");
ftp_login($conn,"user1","user1");
echo ftp_get($conn,"local/p.txt","server/p.txt",FTP_ASCII);    
ftp_close($conn);
?> 

Can Anyone Can Help me please.

divyakrishnan 20 Junior Poster

Hi all,
I want to block some of the special charcters using preg_match.
I used following code.It works fine with including ' and ".
After including ' and " it willnot working

<?php
if($_REQUEST['sub'])
{
$Data=$_REQUEST['data'];

$regexp = '/[#$%^&*+={}<>\'\"]+$/';
echo preg_match($regexp, $Data);
                    if (preg_match($regexp, $Data)) 
                    {
                        echo "ERROR";
                    }
}
?>
<form>
<input type="text" name="data" >
<input type="submit" name="sub">
</form>

Please help me.

divyakrishnan 20 Junior Poster

Hi,

I want to upload a file from one machine to another server ie application is in server A and path of the uploaded file is in server B. How can I implement this without using curl, ftp and ssh. The code which I have used is shown below. But it is not working

<form action="" method="post" enctype="multipart/form-data">
   <input type="file" name="vchr_req_upload" id="vchr_req_upload" />
    <input type="hidden" name="key" value="asdf1234sadfasfd34565xx" />
    <input type="submit" name="submit"> 
</form>

    <?php 

    if(isset($_REQUEST['submit']))
{
    echo $filename=basename($_FILES['vchr_req_upload']['name']);
        $path_info = pathinfo($filename);

             $target_path = "http://192.168.1.29/uploads/";
            $filename=basename($_FILES['vchr_req_upload']['name']);

            if ($_FILES["vchr_req_upload"]["error"] > 0)
            {
                echo "Apologies, an error has occurred.";
                echo "Error Code: " .$_FILES["vchr_req_upload"]["error"];
            }
            else
            {

                $res=move_uploaded_file($_FILES["vchr_req_upload"]["tmp_name"],$target_path);


            }
            }

        ?>
divyakrishnan 20 Junior Poster

The above code will display the name and IP of server.Actually I want to display the IP addrsses of all systems which are connected in a LAN by running a php script.Is it possible?

divyakrishnan 20 Junior Poster

Hi..

Any PHP code to display the IPaddress of all systems which are connected in a LAN ?

Thanks in advance

divyakrishnan 20 Junior Poster

Hi..

I am doing an online quiz software.I have total 100 questions with 5 in each page.I want to go to a particular question number and I want to fix the focus on that question(Not on the top of the page).Each question is inside a label.I am calling a function for that.I used following code.

function goto_quest(qid,cid)
{
var serial=$('#gotq').val(); 
var total_quest=$('#total_quest').val(); 
var perpage=$('#perpage').val(); 

$(document).ready(function()
{   
$.post("gotopage.php", {serial:serial,cid:cid,perpage:perpage,total_quest:total_quest},function(data)
                        {
var serial1=parseInt(serial)-1;

var lid="lab"+serial1;

window.location = "example.php?page="+data;

alert(lid);

document.getElementById(lid).scrollIntoView();
document.getElementById("gotq").selectedIndex=serial1;
 });
 });
}

The script working fine if I use an alert on line number 19.If I comment the alert focus is not working

divyakrishnan 20 Junior Poster

Thanks for the reply...
I want check boxes. That is our client requirement

divyakrishnan 20 Junior Poster

Hi..

I have a group of checkboxes and I want to apply a style to checked checkbox and remove the style of all other boxes.Here only one checkbox should be cheked at a time.

The code I used as follows

<script type="text/javascript" src="jquery-1.7.1.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
    $(".item").click(function(e) {
        //$(".item").each( function() {
            $(".subscribe").attr('checked', false);
        var checkbox = $(this).find(":checkbox"),
            checked = checkbox.is(":checked");
            //alert(checkbox);
            //checkbox.prop("checked", false);

        if (checked) {

            $(this).attr('checked','checked');
            $(this).css("background-color", "#d1d1d1");
        } else {
            $(this).css("background-color", "#03d100");
        }
        checkbox.prop("checked", !checked);
    });
    $('.item :checkbox').click(function() {
      $(this).parent('li').click();
    //})
      })
});
</script>
<ul class="col-1">
    <li class="item">
        <input type="checkbox" name="subscribe[]" class="subscribe" value="Email" id="subscribe_0" />

        <label for="">Check Up</label>
        <span class="float-r">$19</span>
    </li>
    <li class="item">
       <input type="checkbox" name="subscribe[]" class="subscribe" value="SMS" id="subscribe_1" />

        <label for="">Check Up</label>
        <span class="float-r">$19</span>
    </li>
     <li class="item">
<input type="checkbox" name="subscribe[]" class="subscribe" value="Radio" id="subscribe_2" />
        <label for="">Check Up</label>
        <span class="float-r">$19</span>
    </li> <li class="item">
<input type="checkbox" name="subscribe[]" class="subscribe" value="Radio" id="subscribe_3" />
        <label for="">Check Up</label>
        <span class="float-r">$19</span>
    </li>
</ul>
divyakrishnan 20 Junior Poster

Hi..
I used the following code to download a file from fedora 14 FTP configured(VSFTP) to local machine(Fedora 14).
The same code worked fine in windows machine.

In fedora machine it listing all the files,but not downloading the files.Showing the error like following

"There was a problem".

<?php

$countfiles = 0;



$conn_id = ftp_connect("192.16.30.2");





$login_result = ftp_login($conn_id, "usertest", "password");

if($login_result){

printf("****We are now connected****");

printf("<br>");

}else{

printf("****Connection faild****");

printf("<br>");

}





//$buff = ftp_rawlist($conn_id, '/var/www/html/');





 // print_r($buff);

$contents = ftp_nlist($conn_id, "lib/images/");
 print_r($contents);
 $server_file="lib/images/".basename($contents[6]);
echo  "<br>serverfile==".$server_file;
echo $local_file= $server_file;
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {

    echo "Successfully written to $local_file\n";

} else {

   echo "There was a problem\n";

}     





?>

No problem with the connection and directory listing.

divyakrishnan 20 Junior Poster

Is it possible to download the files in a directory using curl in PHP?

divyakrishnan 20 Junior Poster

Hi..

Thanks for your reply.
I used following code.
Its working well but it displaying the message "please wait..." repeatedly on the screen.
Is there any way to show the message only once when download progress.

<?php



  $url  = 'http://192.168.1.40/example/example.pdf';
  $path = 'example.pdf';
    $fp = fopen($path, 'w');






$ch = curl_init( $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt( $ch, CURLOPT_NOPROGRESS, false );

curl_setopt( $ch, CURLOPT_PROGRESSFUNCTION, 'progressCallback' );

curl_setopt( $ch, CURLOPT_FILE,  $fp );

curl_exec( $ch );
fclose($fp);



function progressCallback( $download_size, $downloaded_size, $upload_size, $uploaded_size )

{

echo "please wait...";
static $previousProgress = 0;

if ( $download_size == 0 )

$progress = 0;

else

$progress = round( $downloaded_size * 100 / $download_size );

if ( $progress > $previousProgress)

{


$previousProgress = $progress;

$fp = fopen( "example.pdf", 'a' );

fputs( $fp, "$progress\n" );

fclose( $fp );

}


}
echo "<script>window.location='completion.php'</script>";


?>
divyakrishnan 20 Junior Poster

HI..

I need a progress bar foe downlaoding a file from host serevr using CURL
The downloaded script is working fine.
can anyone suggest code for a progress bar for curl downlaod?

divyakrishnan 20 Junior Poster

Tell me the regular expression used to validate letters,dot(.),slash(/),underscore(_) in JQUERY

divyakrishnan 20 Junior Poster

How to change collation of a mysql table which is created on MYSQL 4.1.22 ?
I used following query

ALTER DATABASE  `testdb` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci

ALTER TABLE  `testtab` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci

It displaying following error messages

****Error

SQL query:

    ALTER DATABASE `testdb` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci

MySQL said: Documentation

    #1064 - You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci' at line 1








Error

SQL query:

    ALTER TABLE `testtab` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci

MySQL said: Documentation

    #1064 - You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci' at line 1 

****
divyakrishnan 20 Junior Poster

Search text is not in fixed format.
It varies.
How to change the query to select the data with all possible formats..

divyakrishnan 20 Junior Poster

I have a search engine to search records from mysqldb.

The script used as follows.

$text=$_REQUEST['txt'];
    $q="select * from table where field regexp '$text' ";

I want to get all records from database with and without space character.

For example If $text="KG 1957" or $text="KG1957"
I want all the records containing KG 1957 & KG1957

divyakrishnan 20 Junior Poster

Thanks.
How to generalize this query to use with a search engine?

divyakrishnan 20 Junior Poster

Hi...
I am using following query to get data from a table

select * from emp where ename regexp 'rajkiran'

It will return only the rows with ename=rajkiran

but I want to select all the rows with ename =raj kiran & ename=rajkiran using a single query

divyakrishnan 20 Junior Poster

Hi..
I used following regular expression "/^[0-9]{1,2}-[0-9]{1,2}-[0-9]{4}$/" for email validation.
It won't check the mail id like "testmail@gmail" .
It will work "testmail@gmai"

Can anybody suggest solution for this?

divyakrishnan 20 Junior Poster

Hi,,
Is it possible to get IP of server where the script is running.
I used following code

<?php 
echo $ip=$_SERVER['REMOTE_ADDR'];
echo  $_SERVER['SERVER_ADDR'];
?>

But it outputing as "127.0.0.1".
Is there any way to print IP ?

divyakrishnan 20 Junior Poster

Hi,
I want a regular expression to validate only numbers(0-9) , dot(.),slash(/) in javascript/JQuery .