Jump to content

zero742

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

zero742's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Fixed the problem this morning. Apparently there is a bug in the mt_rand function that after a certain number of iterations, the function gets "stuck" and produces the same result over and over. It is intermittent and therefore never gets stuck in the same spot or on the same number. As soon as I replaced mt_rand with array_rand (which is probably a better choice anyway...) the problem was immediately solved. Bazinga!
  2. Tried... but no I can provide the Create Table SQL code and some dummy data if that would be helpful.
  3. I've been working on some code to: 1. Search a db for rows that have a particular "position" value 2. Search the same db for rows that have a particular "langs" value 3. Compare the two arrays resulting for 1 and 2 4. Create a multidimensional array $langsarray[langs][question id] if 3 is true. 5. For each langs array in $langsarray pick a random, non-duplicate value and add it to $qarray for a maximum of 12 elements (3 for each langs). What I have works about 95%. The problem is, in the first langs array, one of the 3 randomly picked values is almost always empty, and its not always the same element. Sometimes its the first, sometimes its the third, sometimes its the second... I think I've narrowed down the issue to line 44 ($qtemp = ...). If I change the min/max values for the mt_rand function, it behaves slightly differently. Any help is much appreciated! Thanks in advance. Code: //Include MYSQL class and authentication information require_once('./include/mysql.php'); require_once('./include/global.php'); //Grab apptype from URL querystring $apptype = $_GET['apptype']; //Declare arrays $qarray = array(); $posarray = array(); $langs = array(); $langsarray = array(); //Get id's of all questions pertaining to position type $sql = 'SELECT * FROM qa WHERE position = "' . $apptype . '"'; $result = $db->query($sql) or die(mysql_error()); while ($row = $result->fetch()) { $posarray[] = $row['id']; } //Determine what types of questions should be pulled if ($apptype == 'fed'){ $langs = array('html','css','javascript','jquery'); } else if($apptype == 'bed'){ $langs = array('php','asp','javascript','jquery'); } //Get each question of each language that matches the position type and store it in the multidimensional array $langsarray[language][question id] $z = 0; while ($z < count($langs)){ $sql = 'SELECT * FROM qa WHERE langs = "' . $langs[$z] . '"'; $result = $db->query($sql) or die(mysql_error()); while ($row = $result->fetch()) { if (in_array($row['id'],$posarray)){ $langsarray[$langs[$z]][] = $row['id']; } } //Takes a random question id from the current language ($z) and adds it to the final question array. $y = 0; while ($y < 3) { //$qtemp = $langsarray[$langs[$z]][mt_rand(0,count($langsarray[$langs[$z]]))]; $qtemp = $langsarray[$langs[$z]][mt_rand(0,count($posarray))]; if (!in_array($qtemp,$qarray)){ $qarray[] = $qtemp; echo $qtemp . ', '; $y++; } } echo $langs[$z]; print_r( $langsarray[$langs[$z]]); echo '<br />'; $z++; } echo '<br />'; print_r($qarray); Output: 5, , 2, htmlArray ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) <--Problem 7, 6, 9, cssArray ( [0] => 6 [1] => 7 [2] => 8 [3] => 9 [4] => 10 ) 14, 15, 13, javascriptArray ( [0] => 11 [1] => 12 [2] => 13 [3] => 14 [4] => 15 ) 21, 17, 20, jqueryArray ( [0] => 16 [1] => 17 [2] => 18 [3] => 19 [4] => 20 [5] => 21 ) Array ( [0] => 5 [1] => [2] => 2 [3] => 7 [4] => 6 [5] => 9 [6] => 14 [7] => 15 [8] => 13 [9] => 21 [10] => 17 [11] => 20 ) <-- Final $qarray
  4. I think you may be right. I started checking out my if's and found one dealing with a cookie that might be wrong. I'll check that out. Thanks.
  5. This made progress of sorts. Now instead of an error, it produces a blank page.
  6. I've tried it both ways (replacing ' with \' and ' with ", where appropriate) and get the same result. <?php show '<object codebase=\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\' id=\'doc_804151193636402\' name=\'doc_804151193636402\' classid=\'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\' align=\'middle\' height=\'500\' width=\'100%\' >'; show '<param name=\'movie\' value=\'http://d1.scribdassets.com/ScribdViewer.swf?document_id=20832349&access_key=key-1hrozrvk2nlygfx36t1j&page=1&version=1&viewMode=\'>'; ?> <?php show '<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="doc_804151193636402" name="doc_804151193636402" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle" height="500" width="100%" >'; ?>
  7. I just went through and replaced all the " with ' and I am getting the same errors. <?php if ($pass != $info['password']) { header('Location: login.php'); } else { print '<object codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' id='doc_804151193636402' name='doc_804151193636402' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' align='middle' height='500' width='100%' >'; print '<param name='movie' value='./flash/book.swf'>'; print '<param name='quality' value='high'>'; print '<param name='play' value='true'>'; print '<param name='loop' value='true'>'; print '<param name='scale' value='showall'>'; print '<param name='wmode' value='opaque'>'; print '<param name='devicefont' value='false'>'; print '<param name='bgcolor' value='#ffffff'>'; print '<param name='menu' value='true'>'; print '<param name='allowFullScreen' value='true'>'; print '<param name='allowScriptAccess' value='always'>'; print '<param name='salign' value=''>'; print '<embed src='./flash/book.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' play='true' loop='true' scale='showall' wmode='opaque' devicefont='false' bgcolor='#ffffff' name='doc_804151193636402_object' menu='true' allowfullscreen='true' allowscriptaccess='always' salign='' type='application/x-shockwave-flash' align='middle' height='650' width='100%'>'; print '</embed>'; print '</object>'; echo '<a href=logout.php>Logout</a>'; } } } ?>
  8. This is my first major project in PHP and I'm having some trouble embedding a flash object in an Else statement. I've googled it several times, and looked at several sites and they all seem to suggest displaying it with show or echo or print. I've tried them all and show returns: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/content/m/b/a/mbaveterans/html/Network/resumebook.php on line 107 echo returns: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/content/m/b/a/mbaveterans/html/Network/resumebook.php on line 107 print returns: Parse error: syntax error, unexpected T_STRING in /home/content/m/b/a/mbaveterans/html/Network/resumebook.php on line 107 The If..Else statement is below <?php if ($pass != $info['password']) { header("Location: login.php"); } else { print "<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="doc_804151193636402" name="doc_804151193636402" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle" height="500" width="100%" >"; print "<param name="movie" value="./flash/book.swf">"; print "<param name="quality" value="high">"; print "<param name="play" value="true">"; print "<param name="loop" value="true">"; print "<param name="scale" value="showall">"; print "<param name="wmode" value="opaque">"; print "<param name="devicefont" value="false">"; print "<param name="bgcolor" value="#ffffff">"; print "<param name="menu" value="true">"; print "<param name="allowFullScreen" value="true">"; print "<param name="allowScriptAccess" value="always">"; print "<param name="salign" value="">"; print "<embed src="./flash/book.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" loop="true" scale="showall" wmode="opaque" devicefont="false" bgcolor="#ffffff" name="doc_804151193636402_object" menu="true" allowfullscreen="true" allowscriptaccess="always" salign="" type="application/x-shockwave-flash" align="middle" height="650" width="100%">"; print "</embed>"; print "</object>"; echo "<a href=logout.php>Logout</a>"; } } } ?> Any ideas would be much appreciated. Thanks in advance.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.