Author Topic: Webdeveloping Questions  (Read 7840 times)

0 Members and 1 Guest are viewing this topic.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Webdeveloping Questions
« 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!

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6265
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Webdeveloping Questions
« Reply #1 on: April 03, 2012, 10:13:46 am »
What's the generated code look like?
/e

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Webdeveloping Questions
« Reply #2 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 () {};

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Webdeveloping Questions
« Reply #3 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?

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6265
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Webdeveloping Questions
« Reply #4 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 ;)
/e

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Webdeveloping Questions
« Reply #5 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.

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Webdeveloping Questions
« Reply #6 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?

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Webdeveloping Questions
« Reply #7 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:
* Sorunome needs to bug albertro
« Last Edit: January 14, 2013, 12:08:14 am by Sorunome »

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Webdeveloping Questions
« Reply #8 on: January 14, 2013, 12:06:44 am »
The only thing I see is that your mysql server has a problem.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Webdeveloping Questions
« Reply #9 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:
* Sorunome needs to bug albertro

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Webdeveloping Questions
« Reply #10 on: January 14, 2013, 12:10:44 am »
Yeah, Albert should be able to fix it.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Webdeveloping Questions
« Reply #11 on: January 14, 2013, 12:11:12 am »
He's also the one who set it up, LOL >.<

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Webdeveloping Questions
« Reply #12 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:

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!