Jump to content

phpfreakjav

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Everything posted by phpfreakjav

  1. <?php function http_file_exists($url) { $f=@fopen($url,"r"); if($f) { fclose($f); return true; } return false; } ?>
  2. Like a webservice. Very interesting. I will find out and come back to tell you the issue.
  3. Hello I have a question in regards to design. No need for example code just of how to approach the problem. Issues and things that cannot change because they are part of the situation. 1. Cannot use any database like oracle, MySQL, or SQLite 2. The server does not run PHP5 3. The students do not have a unique field and cant have one because they have not my employers have not decided on one. Here is the problem: I have to make a form with the following fields first name last name comments date I have stored the fields in a text file. However, how can I relate date to the comment without having duplicates records? For example. Lets suppose my boss asked me can you look up the comments that the counselor made in july 10 2010. My answer: One must have duplicate records of each instance of a comment. Am I wrong?
  4. Hi here is a complete userRegistration check class. It allows you to check in any Database whether a user has entered the correct user Name and password. You might have to update the include 'pathofdirectory' lines. I have included all files GOOD LUCK AND THANKS AGAIN [attachment deleted by admin]
  5. I am new to php syntax. My question is: The function checkIdExist returns a string how can I access the string in my client. <?php //this is my client code include "UserRegistration.php"; $user = new UserRegistration(); $user->setName("jose"); $user->checkIdExist("Name","SELECT Name From Users WHERE Name='jose'"); print gettype($user); ?> <?php require_once('../databaseConnection/DbConnector.php');//assume all of this code is correct //class code class UserRegistration { var $name; var $mName; var $lName; var $userId; function getName() { return $this ->name; } function setName($fName) { $this->name=$fName; } function getMName() { $this->mName; } function setMName($mName) { $this->mName = $mName; } function setLname($x) { $this->lName =$x; } function getLName() { $this -> lName; } function getUserId() { return $this->userId; } function setUserId($id) { $this -> userId =$id; } function checkIdExist($columnName,$query) { $connector = new DbConnector(); $id=$this->getName(); $result = $connector->query($query);//change this to meet your needs $num=mysql_numrows($result); $row = $connector->fetchArray($result);// this is a multidimensional array 2x2 [][] if($row[$columnName]== $id){ return "HOW CAN I ACCESS YOU"; } else return "WHERE DID THIS RESULT GO?"; } } ?>
  6. That's all the code there is in test.php no more no less.
  7. 1.I am using xamp to run my server. The default configuration. 2.I have a code by http://code.google.com/p/smt2/ ( a mouse movement tracking script) 3. I have test2.php file.which contained the following code <html> <head> <script type="text/javascript" src="/smt2/core/js/smt-aux.min.js"></script> <!--files from smt project--> <script type="text/javascript" src="/smt2/core/js/smt-record.min.js"></script><!-- files from smt project--> </head> <body> <img src="images/rectangle.php" /><!-- this is the image created by rectangle.php--> </body> </html> 4. I have a rectangle.php script which contains the following code <?php header("Content-type: image/png"); $image = imagecreate( 700, 500); $red = imagecolorallocate($image,0,0, 0); imagepng($image); imagedestroy($image); ob_flush(); ?> I am getting this error when I try to replay the mouse movements through the script from http://code.google.com/p/smt2/ Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\test.php:1) in C:\xampp\htdocs\test.php on line 2 PNG (smt) canvas layer. Enable JavaScript and Flash to replay this log! The odd thing is , that even if i get rid of test.php (delete the file) I still get the error mentioned above when I try to use the mouse tracking script. Also, before I sent the header(Content-type:image/png); the script worked just fine. After I sent the headers the script started crashing.
  8. http://www.phpfreaks.com/forums/index.php/topic,255426.0.html
  9. Question is how can I make the header back to default. In other words to return to the state that it was before I sent the header. <?php header("Content-type: image/png"); $image = imagecreate( 700, 500); $red = imagecolorallocate($image,0,0, 0); imagepng($image); imagedestroy($image); ob_flush();// is this is supposed to get rid of the header? ?>
  10. Problem 1 : is not following my css command CHECK THE displayx function Problem 2 : is giving me a comma in the last digit. Thanks for all your help <html> <head> <title>Accuracy Testing System for Parkinson Patients</title> <meta http-equiv="content-Type" content="text/html;charset=gb2312"> <style type="text/css"> .box1{float:left;} .box2{float:left;} </style> </head> <body onmousemover="follow()"> <!--<body></body>--> <center><img src="Images/MainHome72b.gif"></center> <br><script language="JavaScript"> <!-- var mousex=new Array(); var mousey=new Array(); var timecounter=new Array(); var d = new Date(); var getmin=new Array(); var i; var j=0; var k; var recordcount=0; var repeat; var repeat2; var repeat3; var speed=50; var timerate=20; //milliseconds ; //getUTCMilliseconds() timecounter[0]=0; function startthis() { recordcount=1; i=0; mousex=new Array(); mousey=new Array(); recordthis(); } function recordthis() { getmin[0]=d.getUTCSeconds()+d.getUTCMilliseconds()/1000; if (maxnum.value=='' || isNaN(maxnum.value) == true || maxnum.value<0) { if (recordcount==1) { mousex[i]=mousefollow.offsetLeft; mousey[i]=mousefollow.offsetTop; i++; timecounter[i]=timecounter[i-1]+timerate; getmin[i]=getmin[i-1]+timerate/1000; k=i; textfield.value='No Time Limit'; } } else { if (recordcount==1) { if (i<maxnum.value) { mousex[i]=mousefollow.offsetLeft; mousey[i]=mousefollow.offsetTop; i++; timecounter[i]=timecounter[i-1]+timerate; getmin[i]=getmin[i-1]+timerate/1000; k=i; textfield.value='Time Left'+(maxnum.value-i)+'/50seconds'; } else { recordcount=0; textfield.value='Time is Over';} } } repeat=setTimeout("recordthis()",timerate); } function stopthis() { clearTimeout("repeat"); recordcount=0; } function playthis() { clearTimeout("repeat"); clearTimeout("repeat3"); recordcount=0; if (j<i-1) { arrow.style.pixelLeft=mousex[j]; arrow.style.pixelTop=mousey[j]; arrow.style.visibility='visible'; j++; repeat2=setTimeout("playthis()",speed); } else {clearTimeout("repeat2"); arrow.style.visibility='hidden'; j=0; } } function displayx(x) { document.write(' <div class="box1"> '); for(var i =0; i<mousex.length; i++) { if(i==0) { document.write(mousex[i]) ; document.write("<br/>") ; } if(i==mousex.length) { document.write(mousex[i]) ; document.write("<br/>") ; } else { document.write(mousex[i]) ; document.write(",");//a comma document.write("<br/>") ; } }//end for document.write("</div>"); }//end function function showthis(){ displayx(mousex); // document.write("x: " + mousex + "<br>y: " + mousey +"<br><br><br>The time interval (record the mouse position vector) is every"+ timerate + " milliseconds" + "<br>recorded time (millisec): " + //timecounter+"<br>real time: " +getmin); // document.write("\n sss " ; } function rewindthis() { clearTimeout("repeat"); clearTimeout("repeat2"); recordcount=0; if (k>0) { arrow.style.pixelLeft=mousex[k-1]; arrow.style.pixelTop=mousey[k-1]; arrow.style.visibility='visible'; k--; repeat3=setTimeout("rewindthis()",speed); } else {clearTimeout("repeat3"); arrow.style.visibility='hidden'; k=i; } } function follow() { mousefollow.style.pixelLeft=document.body.scrollLeft+event.clientX; mousefollow.style.pixelTop=document.body.scrollTop+event.clientY; /*mousefollow.style.pixelLeft=document.getElementById('scrollLeft')+event.clientX; mousefollow.style.pixelTop=document.getElementById('scrollTop')+event.clientY;*/ } // --> </script> <div id="arrow" style="position:absolute; width:12px; height:21px; z-index:1;visibility:hidden"><img src="Images/Cursor.gif"></div> <div id="mousefollow" style="position:absolute; width:12px; height:21px; z-index:1;visibility:hidden">.</div> <input type="text" name="maxnum" size="4" maxlength="4"> <input type="button" onClick="startthis()" value="Record"> <input type="button" onClick="stopthis()" value="Stop"> <input type="button" onClick="speed=50;playthis()" value="Play"><input type="button" onClick="speed=2;playthis()" value="Fast Play"> <input type="button" onClick="speed=150;playthis()" value="Slow Play"> <input type="button" onClick="speed=50;rewindthis()" value="Reverse Play"> <input type="button" name="textfield" style="width:100px" value="No Time Limit"> <input type="button" onClick="speed=50;showthis()" value="Show Mouse values"> <br><br><br> <center><img src="Images/bg.png"></center> </body> </html>
  11. Notice in the mysql query it says, values, how to I insert variables here. <?php // Get the PHP file containing the DbConnector class require_once('DbConnector.php'); // Create an instance of DbConnector $connector = new DbConnector(); // Use the query function of DbConnector to run a database query // (The arrow -> is used to access a function of an object) in other words to grab the variables in the Methods //$result = $connector->query('SELECT x FROM coordinates where x >0');//MySQL query goes here $result = $connector->query('INSERT INTO coordinates (x,y,t) VALUES(1,2,3)'); //coordinates is the table name, xyt are the //columns, and values are the values recorded by the mouse //script. // Get the result $row = $connector->fetchArray($result); ?>
  12. I just wanted to share this code because it took me a while to figure howto do this. <html> <head> <script language="Javascript"> //alternative 1 function php_serialize(obj) { var string = ''; if (typeof(obj) == 'object') { if (obj instanceof Array) { string = 'a:'; tmpstring = ''; count = 0; for (var key in obj) { tmpstring += php_serialize(key); tmpstring += php_serialize(obj[key]); count++; } string += count + ':{'; string += tmpstring; string += '}'; } else if (obj instanceof Object) { classname = obj.toString(); if (classname == '[object Object]') { classname = 'StdClass'; } string = 'O:' + classname.length + ':"' + classname + '":'; tmpstring = ''; count = 0; for (var key in obj) { tmpstring += php_serialize(key); if (obj[key]) { tmpstring += php_serialize(obj[key]); } else { tmpstring += php_serialize(''); } count++; } string += count + ':{' + tmpstring + '}'; } } else { switch (typeof(obj)) { case 'number': if (obj - Math.floor(obj) != 0) { string += 'd:' + obj + ';'; } else { string += 'i:' + obj + ';'; } break; case 'string': string += 's:' + obj.length + ':"' + obj + '";'; break; case 'boolean': if (obj) { string += 'b:1;'; } else { string += 'b:0;'; } break; } } return string; } function displayArray(x) {//only displays 1 dimensional array for (i=0;i<x.length;i++) { document.write(x[i] + "<br >"); } } //alternative 2 function js_array_to_php_array (a) // This converts a javascript array to a string in PHP serialized format. // This is useful for passing arrays to PHP. On the PHP side you can // unserialize this string from a cookie or request variable. For example, // assuming you used javascript to set a cookie called "php_array" // to the value of a javascript array then you can restore the cookie // from PHP like this: // <?php // session_start(); // $my_array = unserialize(urldecode(stripslashes($_COOKIE['php_array']))); // print_r ($my_array); // ?> // This automatically converts both keys and values to strings. // The return string is not URL escaped, so you must call the // Javascript "escape()" function before you pass this string to PHP. { var a_php = ""; var total = 0; for (var key in a) { ++ total; a_php = a_php + "s:" + String(key).length + ":\"" + String(key) + "\";s:" + String(a[key]).length + ":\"" + String(a[key]) + "\";"; } a_php = "a:" + total + ":{" + a_php + "}"; return a_php; } var x = new Array("1","2"); var x1=new Array(); x1=x; displayArray(x); displayArray(x1); document.write("Serializing starts <br/>"); x=php_serialize(x); displayArray(x); document.write("Serializing starts <br/>"); x1=js_array_to_php_array(x); displayArray(x1); escape(); </script> </head> <body></body> </html>
  13. I solved that issue after putting the data into a function call like this : This function shows how to pass an array onclick in flash to php. var testing = new Array(); testing[0]="american explorer"; sData.onRelease = function() { sender.testing = testing[0]; sender.send('http://localhost/crazy_experiments/biomed/results.php','','POST'); } php code is $dataReceived= array($HTTP_POST_VARS["testing"]);//multidimensional array
  14. Now something unexpected happened. The website seems the reload very often as if it was still communicating with flash. ???
  15. I solve the problem! The problem was that I was running the movie as a standalone swf file. When I inserted the movie into html <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="550" height="400" accesskey="1" tabindex="2" title="Mouse"> <param name="movie" value="14.swf"> <param name="quality" value="high"> <embed src="14.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="550" height="400"></embed> </object> The problem was fixed! thanks for making me think!
  16. I have a flash movie that sends data to results.php var sender = new LoadVars(); sender.xy = "someVariableValue"; sender.send('http://localhost/crazy_experiments/biomed/results.php', '', 'POST'); The result of this command is that the url in results.php appends to the following http://localhost/crazy_experiments/biomed/results.php?xy=someVariableValue The question: How do I grab the someVariableValue String from the url.
  17. By the way when I use the code above I get a new window in firefox and the url says http://localhost/crazy_experiments/biomed/results.php?xy=xxx NOTE THAT THE xxx is the variable I sent through flash but now I cant get it to be a variable in php! how can I get xy to be a variable in php
  18. var sender = new LoadVars(); sender.SOMEVALUE= "xxx"; sender.send("http://localhost/crazy_experiments/biomed/results.php", "", "POST"); How do I check that the SOMEVALUE was sent? Would this work? <?php $x =$_POST['SOMEVALUE']; //????? ?>
  19. Yes, that is very smart. If you have a lot of text boxes.
  20. If include doesnt work, then try require_once("")
  21. How do I send a FLASH array into PHP?PLEASE LOOK AT THE CODE. I have indicated which arrays I want to send to php. mouseMC._visible = false; var recording = false; var playing = false; var index = 0; var mPosX = new Array(); var mPosY = new Array(); _root.onEnterFrame = function() { if(recording) { mPosX[index] = _root._xmouse; mPosY[index] = _root._ymouse; index++ } else if (playing) { mouseMC._x = mPosX[index] <<<<I WANT TO SEND THIS ARRAY TO PHP mouseMC._y = mPosY[index] <<<<I WANT TO SEND THIS ARRAY TO PHP index++; if(index == mPosX.length) { Mouse.show(); _root.mouseMC._visible = false; } } } recBtn.onRelease = function() { Mouse.show(); _root.mouseMC._visible = false; _root.recording = true; _root.playing = false; _root.index = 0; _root.mPosX = new Array(); _root.mPosY = new Array(); } playBtn.onRelease = function() { Mouse.hide(); _root.mouseMC._visible = true; _root.recording = false; _root.playing = true; _root.index = 0; } stopBtn.onRelease = function() { Mouse.show(); _root.mouseMC._visible = false; _root.recording = false; _root.playing = false; _root.index = 0; }
×
×
  • 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.