Omnimaga

General Discussion => Technology and Development => Web Programming and Design => Topic started by: Sorunome on April 03, 2012, 08:14:04 am

Title: Webdeveloping Questions
Post by: Sorunome on April 03, 2012, 08:14:04 am
Ok, I decided to launch a thread with webdeveloping questions as I have so many questions....I just like programming stuff for my website :D
Well, first of all, is it possible to open a link in a new tab with Javascript?
Second...Well, I want to store pics in an array (Javascript), the pics are the canvas pics, it is generated dynamic by php, and  want that the nexxt pic won't start loading before the one before was finished.
I wrote this:

Code: [Select]
<?php 
if ($handle opendir($folder))
{
echo "pics = new Array();";
$pics = array();
while (false !== ($entry readdir($handle)))
{
if (preg_match("/[^\.].*\.(jpg|jpeg|png|gif)$/i"$entry))
{
array_push($pics,$entry);
}
}
closedir($handle);
sort($pics);
$j 0;
foreach ($pics as &$pic)
{
echo "function pic$j () {
pics[
$j] = new Image();
pics[
$j].src = &#39;$folder/$pic&#39;;
pics[
$j].";$j++;echo"addEventListener(&#39;load&#39;,pic".$j.",false);
}\n"
;
}
echo "function pic".$j." () {};\n\n\n";
}
?>
Well, the errorkonsole of firefox gives me this:
[14:06:08.411] uncaught exception: [Exception... "The type of an object is incompatible with the expected type of the parameter associated to the object"  code: "17" nsresult: "0x80530011 (NS_ERROR_DOM_TYPE_MISMATCH_ERR)"  location: "[no need to know]"]
Please help me!
Title: Re: Webdeveloping Questions
Post by: Eeems on April 03, 2012, 10:13:46 am
What's the generated code look like?
Title: Re: Webdeveloping Questions
Post by: Sorunome on April 03, 2012, 11:50:15 am
Code: [Select]
<!DOCTYPE html>
<html><head>
<script type="text/javascript">
pics = new Array();
function pic0 () {
pics[0] = new Image();
pics[0].src = '../../knex/ballmachines/crazy/pics/FCLAHGTGD2J1W43.LARGE.jpg';
pics[0].addEventListener('load',pic1,false);
}
function pic1 () {
pics[1] = new Image();
pics[1].src = '../../knex/ballmachines/crazy/pics/FI0ABR4GD2JC4X3.LARGE.jpg';
pics[1].addEventListener('load',pic2,false);
}
function pic2 () {
pics[2] = new Image();
pics[2].src = '../../knex/ballmachines/crazy/pics/FODHF3KGD2JJN69.LARGE.jpg';
pics[2].addEventListener('load',pic3,false);
}
function pic3 () {
pics[3] = new Image();
pics[3].src = '../../knex/ballmachines/crazy/pics/FRG66RIGD2J1W44.LARGE.jpg';
pics[3].addEventListener('load',pic4,false);
}
function pic4 () {
pics[4] = new Image();
pics[4].src = '../../knex/ballmachines/crazy/pics/FSRATY0GD0R0CV4.LARGE.jpg';
pics[4].addEventListener('load',pic5,false);
}
function pic5 () {
pics[5] = new Image();
pics[5].src = '../../knex/ballmachines/crazy/pics/FTWRI1CGD2JC4X6.LARGE.jpg';
pics[5].addEventListener('load',pic6,false);
}
function pic6 () {
pics[6] = new Image();
pics[6].src = '../../knex/ballmachines/crazy/pics/FYQYILGGD2JC4X5.LARGE.jpg';
pics[6].addEventListener('load',pic7,false);
}
function pic7 () {
pics[7] = new Image();
pics[7].src = '../../knex/ballmachines/crazy/pics/FZMZ8OBGD0R0CVA.LARGE.jpg';
pics[7].addEventListener('load',pic8,false);
}
function pic8 () {
pics[8] = new Image();
pics[8].src = '../../knex/ballmachines/crazy/pics/crazy_top.jpg';
pics[8].addEventListener('load',pic9,false);
}
function pic9 () {};
Title: Re: Webdeveloping Questions
Post by: Sorunome on April 03, 2012, 02:51:10 pm
Jacobly helped me out with that array pic stuff, thanks!

And can you open a link in a new tab via javascript?
Title: Re: Webdeveloping Questions
Post by: Eeems on April 03, 2012, 06:40:28 pm
http://stackoverflow.com/questions/4907843/open-url-in-new-tab-using-javascript
http://stackoverflow.com/questions/427479/programmatically-open-new-pages-on-tabs
You should always use google to check for answers to your questions before you post. Not only are you more likely to get your answer faster and thus implement it faster but you also keep others from having to use google ;)
Title: Re: Webdeveloping Questions
Post by: Sorunome on January 13, 2013, 11:53:46 pm
*necrobump*
I have a very wired bug, i have the following php code:
Code: [Select]
<?php
error_reporting
(0);
//ini_set(&#39;display_errors&#39;, &#39;1&#39;);
 
session_start();
$_SESSION[&#39;player&#39;]=1;
$_SESSION[&#39;game&#39;]=1;
$_SESSION[&#39;id&#39;]=1;
$verbindung mysql_connect("localhost","sorunome",<passwd>);
mysql_select_db("risk");
 
if (
$_GET[&#39;action&#39;]=="lines") {
        /*
        $num = mysql_real_escape_string($_GET[&#39;num&#39;]);
        $offset = mysql_real_escape_string($_GET[&#39;offset&#39;]);
        $loop = true;
        $counter = 0;
        $doSleep = true;
        if (max(mysql_fetch_array(mysql_query("SELECT MAX(id) FROM risk")))>=$num)
                $doSleep = false;
        $num = $num-$offset;
        if ($_SESSION[&#39;id&#39;]!==NULL) {
                while ($loop) {
                        if ($doSleep)
                                sleep(1);
                        $result = mysql_fetch_array(mysql_query("SELECT * FROM risk WHERE id=&#39;1&#39;",$verbindung));//".($num+$counter)."
                        die(mysql_error());
                        if ($result) {
                                if ($result["player"]==$_SESSION[&#39;player&#39;] || $result["game"]==$_SESSION[&#39;game&#39;] || $result["player"]=="0") {
                                        echo $result["content"]."\n";
                                        $counter++;
                                } else
                                        $counter++;
                                if ($counter>$offset)
                                        $loop = false;
                        }
                }
                echo "nextLine(\"".($num+$offset+1)."\",0);";
        } else
                echo "lostConnection();";
        */
}
if (
$_GET[&#39;action&#39;]=="send") {
        
$request $_GET[&#39;request&#39;];
        
if ($request=="MAP") {
                
mysql_query("INSERT INTO riskserver (player,game,content) VALUES (&#39;".$_SESSION[&#39;player&#39;]."&#39;,&#39;".$_SESSION[&#39;game&#39;]."&#39;,&#39;MAP&#39;);",$verbindung)or die(mysql_error());
        
}
}
?>
And no matter how i call it I get 504 gateway timeout, yes, that big block IS commented out.
Title: Re: Webdeveloping Questions
Post by: Juju on January 14, 2013, 12:04:33 am
Your error isn't probably related to your php code, as it's a gateway error. Do you have a gateway? Is it timeouting? Do your script takes too long to execute?
Title: Re: Webdeveloping Questions
Post by: Sorunome on January 14, 2013, 12:05:36 am
I have a timeout - 1 minuet, and somehow it takes longer than that, or i don't know what you mean >.<

EDIT: WUT?!?!?! somehow php files load infinity, without php it is working, but it worked earlier today D:/me needs to bug albertro
Title: Re: Webdeveloping Questions
Post by: Juju on January 14, 2013, 12:06:44 am
The only thing I see is that your mysql server has a problem.
Title: Re: Webdeveloping Questions
Post by: Sorunome on January 14, 2013, 12:08:35 am
EDIT: WUT?!?!?! somehow php files load infinity, without php it is working, but it worked earlier today D:/me needs to bug albertro
Title: Re: Webdeveloping Questions
Post by: Juju on January 14, 2013, 12:10:44 am
Yeah, Albert should be able to fix it.
Title: Re: Webdeveloping Questions
Post by: Sorunome on January 14, 2013, 12:11:12 am
He's also the one who set it up, LOL >.<
Title: Re: Webdeveloping Questions
Post by: Sorunome on January 14, 2013, 08:38:15 pm
Ok, the result is now: php crached.
Why did it crach? My server has not enough RAM D: