...

Hi! I’m Starx

experienced Software Developer. And this is my blog
Start Reading About me
Blog Page
November 18, 2010

Unable to upload the file from local machine to server using php function

Question by Meena

i am uploading the file in the servier i am using the below code

   move_uploaded_file($_FILES["uploadfile".$k]["tmp_name"],
  "photoalbum/".$_SESSION["almgid"]."/".$_FILES["uploadfile".$k]["name"]);
  $uploadfile =  "photoalbum/".$_SESSION["almgid"]."/".$_FILES["uploadfile".$k]["name"];

This code is working fine in the local but the images are not uploading in the server how to solve this issue please help me,

this is the error message i am receive during uploading the file in server

Warning: move_uploaded_file(photoalbum/1cutebaby05.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/whspider/public_html/alumnimgmts/editprofile.php

i am already added the enctype=”multipart/form-data” in the form, i already check the image size,

Answer by Starx

IF they are working in local server, then it is the problem related to to authorities.

try

chmod("photoalbum/".$_SESSION["almgid"]."/",0755); // OR 0777 during testing only

before move_uploaded_file

Read more
November 17, 2010

Browser/OS support fonts

Question by waanders

Where can I find a list of browser safe fonts? I mean fonts I can use in my webpages which will be displayed correctly in different browsers and versions both with Windows and Mac.

UPDATE:

Yes, I know how to search with Google. I just thought someone at this forum could give me a link to a matrix with font/browser/browserversion/os support of fonts. Like http://www.quirksmode.org/compatibility.html for CSS support.

I found something that comes close to what I meant:
http://www.upsdell.com/BrowserNews/res_fonts.htm

Answer by Oded

There are such lists:

These is just one good link from a quick google search for “safe web font”.

You can learn quite a lot from the wikipedia entry for Web Typography.

Answer by Starx

Go for most common fonts between all domains. I would suggest Verdana, it is probably one of the widely used font, which is supported by almost all OS.

Or go from one of the following list

font-family: Arial, Helvetica, sans-serif;
font-family: 'Arial Black', Gadget, sans-serif;
font-family: 'Bookman Old Style', serif;
font-family: 'Comic Sans MS', cursive;
font-family: Courier, monospace;
font-family: 'Courier New', Courier, monospace;
font-family: Garamond, serif;
font-family: Georgia, serif;
font-family: Impact, Charcoal, sans-serif;
font-family: 'Lucida Console', Monaco, monospace;
font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
font-family: 'MS Sans Serif', Geneva, sans-serif;
font-family: 'MS Serif', 'New York', sans-serif;
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
font-family: Symbol, sans-serif;
font-family: Tahoma, Geneva, sans-serif;
font-family: 'Times New Roman', Times, serif;
font-family: 'Trebuchet MS', Helvetica, sans-serif;
font-family: Verdana, Geneva, sans-serif;
font-family: Webdings, sans-serif;
font-family: Wingdings, 'Zapf Dingbats', sans-serif;
Read more
November 16, 2010

Create a link on the fly when a user enters a code in a form box

Question by Andy

I have a form….

<form id="orderform" method="post" orderform="" name="">
  <table width="533" cellspacing="0" cellpadding="2" border="0" id="ordertable">
  <tbody>
    <tr>
      <td>Product Code</td>
      <td>Meterage</td>
      <td>Sample Img</td>
    </tr>
    <tr class="item">
      <td class="prodcode"><input type="text" id="prodcode" name="prodcode"></td>
      <td class="meterage"><input type="text" id="meterage" name="meterage"></td>
      <td class="imgsample"></td>
    </tr>
    </tbody>
  </table>
</form>

What i would like is when a user clicks out of the box on the prodcode it searches a folder for the image reference…creates a link on under the imgsample header for that particular item using the prodCode they entered…

http://www.mylink.com/images/folder/sub-folder/imageref.jpg

Is this an impossible task, any ideas?

Answer by Starx

I hope this is what you are asking for.

$("#prodcode").blur(function() {
  $.post(
         'yourpage.php', //this page reads the image code and gives you the image location
         { action: 'searchimage', imgreference: $('#prodcode').val() },
         function(data) { 
             //export the link as data            
             $("td.imgsample").html('<img src="'+data+'"/>');
         }
        );
});
Read more
November 15, 2010

What is wrong with my function? (new to user defined functions)

Question by Mitchell Klein

I am trying to post from a previous page with a form on it, and rather then typing out the code over and over again i tried making a function for it, it didnt work. thanks in advance

function postORempty($field){
isset($_POST[$field]) ? $_POST[$field] : "";
}

$szFname= postORempty('fname');

Answer by Starx

You haven’t returned any value

function postORempty($field){ 
      return isset($_POST[$field]) ? $_POST[$field] : ""; 
}
$szFname= postORempty('fname');
Read more
November 14, 2010

who can suggest one PHP framework?

Question by user507206

Possible Duplicate:
What PHP framework would you choose for a new application and why?

Just like codeingiter or cakephp..yes, i used it before,but who can give me some more chices?
also mvc,support cache,light,qucik and small~~

Thank you very much!

Answer by Alan Haggai Alavi

See phpframeworks.com for a comparison.

Read more
November 12, 2010

Adding child elements (divs) to a parent element (div), how can I stop each child affecting the top value of the child after it?

Question by ben

In this jQuery code, I am dynamically adding boxes to the canvas div like this:

var canvas = $('#canvas');
canvas.append('<div id="1"></div>');
('#1').addClass('ui-boxer')
                .css({ border: '1px solid white',
                       background: 'orange',
                       padding: '0.5em',
                       position: 'relative',
                       'z-index': 100,
                       left: '1%', top: '10%',
                       width: '40%', height: '50%'});

canvas.append('<div id="2"></div>');
$('#2').addClass('ui-boxer')
                .css({ border: '1px solid white',
                       background: 'orange',
                       padding: '0.5em',
                       position: 'relative',
                       'z-index': 100,
                       left: '50%', top: '10%',
                       width: '20%', height: '50%'});

The boxes are created okay, but the top position of the second box is wrong. It’s 10% (like the first box), but it’s clearly not working correctly. I think the presence of the first child is affecting it? How can I set the top value so that it is based of the parent element (the canvas div) and not the child element before it? Thanks for reading.

Answer by Starx

Changed the position to absolute.

Check this
http://jsfiddle.net/heQFB/1/

Read more
November 2, 2010

How to create a jquery timer that starts on keyup

Question by Josh R

I am using jquery 1.4. I want create the timer which starts on keyup event and resets on key press event. I want to use $.ajax request to send the time interval to the server. All I could find was countdown timers.

I appreciate any help.

Thanks

Answer by lonesomeday

You can do this very simply by comparing timestamps using native Javascript functions — no jQuery necessary for the timing logic:

var start, end, interval;

$('form' /*or whatever selector*/).keydown(function() {
    start = new Date();
}).keyup(function() {
    end = new Date();

    interval = end.getTime() - start.getTime(); // interval in milliseconds

    // do your AJAX here
});

Answer by Starx

Why dont you check this link. It is a jquery stopwatch. Go through its coding, may be it will give you some idea.

Read more
October 31, 2010

jQuery vs. javascript?

Question by Adam Kiss

I recently stumbled upon some javascript forums (sadly, link is lost somewhere in the universe), where you could feel real hate against jQuery for not being… any good?

Most arguments seem to make sense actually.

Now, I really like jQuery, mostly for letting me concentrate on things I want to do rather on browser inconsistencies and it actually makes AJAXing with cool (or overused?) effects fun.

But if really is something rotten in the core of jQuery, I don’t want to rely on it the way I actually… rely on it.

I don’t want to start yet another argument over which framework is the best… but… Which framework is the best (joke)? As a case usage, think about small to medium web and it’s administration.

I’m just trying to figure out, if stuff in some framework or pure javascript with few mine functions really makes difference.

Edit:

I actually tried to had a normal objective discusssion over pros and cons of 1., using framework over pure javascript and 2., jquery vs. others, since jQuery seems to be easiest to work with with quickest learning curve. However, some people just don’t understand it and think that I’m starting yet another flame (what I am not). I am actually voting to reopen this question.

Also I’m really interested in:

  • Does jQuery heavily rely on browser sniffing? Could be that potential problem in future? Why?
  • I found plenty JS-selector engines, are there any AJAX and FX libraries?
  • Is there any reason (besides browser sniffing and personal “hate” against John Resig) why jQuery is wrong?

jQuery actually, as most used, stands for other frameworks also.

Answer by Xr.

It’s all about performance and development speed. Of course, if you are a good programmer and design something that is really tailored to your needs, you might achieve better performance that if you had used a Javascript framework. But do you have the time to do it all by yourself?

My personal opinion is that Javascript is incredibly useful and overused, but that if you really need it, a framework is the way to go.

Now comes the choice of the framework. For what benchmarks are worth, you can find one at http://ejohn.org/files/142/ . It also depends on which plugins are available and what you intend to do with them. I started using jQuery because it seemed to be maintained and well featured, even though it wasn’t the fastest at that moment. I do not regret it but I didn’t test anything else since then.

Answer by Starx

Jquery VS javascript, I am completely against the OP in this question. Comparison happens with two similar things, not in such case.

Jquery is Javascript. A javascript library to reduce vague coding, collection commonly used javascript functions which has proven to help in efficient and fast coding.

Javascript is the source, the actual scripts that browser responds to.

Read more
October 29, 2010

div in front of another resets jQuery hover animation. how to prevent this?

Question by MauF

i have an animate effect applied to 4 divs in order to create a blinds effect: when you hover over the first box it grows , the other 3 shrink and when you “mouseout” all 4 return to 25% of the total height.

i want to insert a nested div inside each box (in front, actually with absolute positioning) in order to present some text and links, but every time the mouse hovers over this new div, the animation resets (the mouseout event runs).

how can i make the nested div invisible to the animation? or include it such way that it is invisible to the animation code but the urls work properly?

the example is here:

jquery problem

all code is inline for this demo.

thanx in advance.

Answer by Starx

Solved, check here

The trick to add the selector $("#one > *")

Read more
...

Please fill the form - I will response as fast as I can!