Jump to content

arianhojat

Members
  • Posts

    235
  • Joined

  • Last visited

    Never

Everything posted by arianhojat

  1. Daniel0, well in constructor for the MySQLResultSet there is no & in the constructor func definition, so pass by reference i dont think exists in that case right? class MySQLResultSet{ private $connection; ... public function __construct( $strSQL, $databasename, $connection ){ //not &$connection Jenk, Is the property/resource of the object that is passed in viewed as an object? i can understand if the MySQLConnect object itself is passed in by reference since all Objects passed by reference as you said, but what about properties of objects?
  2. In chapter 9 of Object-Oriented PHP: Concepts, Techniques and Code, it makes an MySQLConnect class which uses a MySQLResultSet class to create a resultset. i was wondering if the $this->connection in the createResultSet() function should be passed as a reference to the mysql connection, currently it is sending a copy of that resource which is wasteful, right? or is it automatically passed as reference since it is an object property. class MySQLConnect { private $connection; ... function createResultSet($strSQL, $databasename){ $rs = new MySQLResultSet($strSQL, $databasename, $this->connection ); return $rs; }
  3. whoops, forgot to say anything within double qoutes is interpreted hence why could include variable inside qoutes in my last example. and yes i did forget to place examples in qoutes. and u seem to found his mistake too... he is putting ORDER BY before the WHERE clause. so jim any of these should work: $query = 'SELECT * FROM patient WHERE patient.last_name ="'. $_SESSION['last_name'] .'" ORDER BY patient.last_name, patient.first_name, patient.mi'; $query = "SELECT * FROM patient WHERE patient.last_name ='". $_SESSION['last_name'] ."' ORDER BY patient.last_name, patient.first_name, patient.mi "; $query = 'SELECT * FROM patient WHERE patient.last_name ="'. $_SESSION["last_name"] .'" ORDER BY patient.last_name, patient.first_name, patient.mi '; $query = "SELECT * FROM patient WHERE patient.last_name =". $_SESSION["last_name"] ."' ORDER BY patient.last_name, patient.first_name, patient.mi "; or that last example where any vars in the double qouted string are interpreted. $query = "SELECT * FROM patient WHERE patient.last_name = {$_SESSION['last_name']} ORDER BY patient.last_name, patient.first_name, patient.mi";
  4. which quotes? doesnt matter, all same $query = 'SELECT * FROM patient ORDER BY patient.last_name, patient.first_name, patient.mi WHERE patient.last_name ='. $_SESSION['last_name']; $query = "SELECT * FROM patient ORDER BY patient.last_name, patient.first_name, patient.mi WHERE patient.last_name =". $_SESSION['last_name']; $query = 'SELECT * FROM patient ORDER BY patient.last_name, patient.first_name, patient.mi WHERE patient.last_name ='. $_SESSION["last_name"]; $query = "SELECT * FROM patient ORDER BY patient.last_name, patient.first_name, patient.mi WHERE patient.last_name =". $_SESSION["last_name"]; prob could also do all within 1 string $query = "SELECT * FROM patient ORDER BY patient.last_name, patient.first_name, patient.mi WHERE patient.last_name = {$_SESSION['last_name']}";
  5. I was looking for a tutorial or lesson online on how to make simple virtual stock market system/database schema... If none available, some help is appreciated with background on what tables i need. So far I have tradables which has every thing that can be tradable in my system and its ticker, tradables_price which has a price at certain time/history. users table, users_balance table, an orders table filled with possible buys/sells. a 'market maker' AI will prob make buys and sells to keep system fluid just like real stock market so stocks are always being traded. Any good open source stock market system i should check out and takes look at what data they store for stocks?
  6. i have a php page which reads GET parameters and if one of the variables is set, then use cURL fucntions to transfer those variables to another webpage. but instead of seeing 'http://intranetServer:8080/reports/view.jsp' in URL, i see 'readParameters.php' still which disturbs me. Anyway way to make it so both content AND URL changes (right now the content on the page is correct)? //readParameters.php if($_GET['action']=='completed') { $url = 'http://intranetServer:8080/reports/view.jsp'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// Follow any Location headers curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);// dont echo output $postfields = $_GET; //tranfser the GET parameters to this jsp page via POST now curl_setopt($ch, CURLOPT_POST, 1);// Alert cURL to the fact that we're doing a POST, and pass the associative array for POSTing. curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $output = curl_exec($ch); curl_close($ch); }
  7. php returns a chunk of code from my database, basically html and also js from a javascript library that creates a nice formatted date popup when you click the associated hyperlink to fill a textfield with after you choose a date... But since i just add the chunk of code to innerHTML, it never runs the javascript needed so clicking the hyperlink doesnt cause the popup object to come up since the JS object wasnt created... I was wondering how to do this. Not sure how to handle this, maybe some sort of function to parse the XML be4hand and pass whatever is inside <script> tags to javascript's eval() function. //php returns this to my AJAX script in a CDATA section in a XML node which i attach to innerHTML echo '<div>'; echo '<script language="Javascript" id="js1"> var startDatePopup = new CalendarPopup(); startDatePopup.setDisplayType("custom"); startDatePopup.showYearNavigation(); startDatePopup.setReturnCustomFunction("funcReturnStart"); function funcReturnStart(y,m,d) {document.getElementById(\'startDate\').value=m+\'/\'+d+\'/\'+y; } </script>'; echo '<span class="label">Start Date:</span>'; echo '<span class="answer"><input type="text" id="startDate" name="customParam[startDate]" value=""/>'; echo '<a href="#" onclick="startDatePopup.showCalendar(\'anchorStartDate\'); return false;" title="Write in this format: 12-25-2006" name="anchorStartDate" id="anchorStartDate">select</a>'; echo '</span>';//will show up if saved or error on form echo '</div>'; echo '<div>'; echo '<script language="Javascript" id="js2"> var endDatePopup = new CalendarPopup(); endDatePopup.setDisplayType("custom"); endDatePopup.showYearNavigation(); endDatePopup.setReturnCustomFunction("funcReturnEnd"); function funcReturnEnd(y,m,d) {document.getElementById(\'endDate\').value=m+\'/\'+d+\'/\'+y; } </script>'; echo '<span class="label">End Date:</span>'; echo '<span class="answer"><input type="text" id="endDate" name="customParam[endDate]" value=""/>'; echo '<a href="#" onclick="endDatePopup.showCalendar(\'anchorEndDate\'); return false;" title="Write in this format: 12-25-2006" name="anchorEndDate" id="anchorEndDate">select</a>'; echo '</span>';//will show up if saved or error on form echo '</div>';
  8. I think this is what i was looking for: String[] paramValues = request.getParameterValues(paramName); for(int i=0; i<paramValues.length; i++) { out.println( paramValues ); }
  9. whoops, just updating this cause had instance again where dynamic form fields processed with javascript after creating it messed up in IE6: i think this one is bulletproof and should handle all situations. Test usage: var lastIndexNewTeachers = ( (insertNewTeachers.length > 0 ) ? (parseInt(insertNewTeachers[insertNewTeachers.length-1].value,10)+1) : 0 );//next value has one more than previous val in this dynamically created array. This value will always be 0 if IE6 cant find dynamic nodes correctly. var insertInput = elem('input', 'insertNewTeachers[]', {type: 'hidden', value: ++lastIndexNewTeachers }, {}, null, {onclick: "function(){ alert(this.AttachedProperty ) } ); insertInput.AttachedProperty = getTodaysDate(); //functions used function createNamedElement(type, name) { var element = null; //Try the IE way; this fails on standards-compliant browsers try { element = document.createElement('<'+type+' name="'+name+'">'); } catch(e) { } if (!element || element.nodeName != type.toUpperCase()) { // Non-IE browser; use canonical method to create named element element = document.createElement(type); element.name = name; } return element; } function elem(type, name, attrs, style, text, handlers) { var e = createNamedElement(type, name); if (attrs) { for (key in attrs) { if (key == 'class') { e.className = attrs[key]; } else if (key == 'name') { } else if (key == 'id') { e.id = attrs[key]; } else { e.setAttribute(key, attrs[key]); } } } if (style) { for (key in style) { e.style[key] = style[key]; } } if (text) { e.appendChild(document.createTextNode(text)); } if (handlers) { for (key in handlers) { //alert('setting handler'); eval( 'var x =' + handlers[key] ); //eval( "var x = function(){ alert('xxx') };" ); eval('e.'+key+'= x'); //e.onclick = x; //e.onclick = function(){ alert('xxx') }; } } return e; }
  10. already looked at java apis. i think php might be unique in this regard and made it easier to look at html form vars as arrays and java just sucks
  11. Asked in java forum, but i guess they avoided me Want to do something like this in java: //visit following url: //test.php?page=1&reloadReport=true&params[startDate]=2/7/2003&params[endDate]=2/7/2003&params[firstName]=John&etc=could be many many unknown vars in params //and easily loop over to put in array for further processing foreach( $_GET['params'] as $key=>$val) { $params[$key] = $value; } createReport($params); //my java psuedocode: Map parameters = new HashMap(); ArrayList params = (ArrayList) request.getParameter("params"); for( String key=>value : params ) { params.put( key, value ); } createReport(params);
  12. Hey jesirose, had a few questions... 1. this is the easy question i think: why set HEADER to 1 1t first, i assume cause cookies are stored in session and you want them to goto login script , so you have to explicitly say so? other curl cookie examples i saw didnt have HEADER set to 1, so i assume this was to be explicit. 2. next question : just curious why did u set Header to 0 so it doesnt send header to next url once logged in? just wondering why it hurts to include header?, in fact it seems like you should so u can 'pass along on cookie info' to next page so the next page knows you are signed in. no yes? and 3. i guess maybe the SSL optins i wasnt sure what they were for either.: curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); thanks so much for your help!. Ari
  13. Bascially i use cURL to log into a website, but i want to display that website in an iframe on my php page. anyway to do this? iframe's src is the web address but i need to login to the webpage be4. I will test later, but maybe the curl code which logs in will set the cookie, and i dont need to worry about it and can just supply url to want to goto. Any params I need to worry about for the cookie?
  14. if u want to do it the recursive way, u should return something in the 'else' right (been a while since i did recursion)? and dont call the function test. it will recursively return the code to the '1st' function that called it; function get_unique_activ_code(){ $code = make_code(); $q = "select from `table` where Code = '".$code."'"; $r = mysql_query($q) or die(mysql_error()); if(mysql_num_rows($r){ //We found a match lets re roll code $anothercode = get_unique_activ_code(); return $anothercode; } else{ return $code; } } $unique = get_unique_activ_code();
  15. i dont think u need to search your database for unique activation code. Make random timestamp and then encrypt in as password in database. u can make random without checking database with : $tempActivationpassword = md5( uniqid(rand(), true) ); //makes strong unique randompassword then md5's it so actual activation 'password' code isnt stored in database. or $tempActivationpassword = md5( microtime() ); //kinda like previous user said.
  16. possibly php uniqid() func. for($i=0; $i<10; $i++) $randNum = uniqid(); u said u make your own, but why not use php's. think it makes a random one based on the time each time its called.
  17. Just was interested in an example where you login via cURL to Yahoo Finance. This seemed much more complicated than logging into a standard form. Seems like some redirects involved 1st time I tried it many months ago (couldnt find any meaty tutorials at the time that dealt with suff other than barebones POST logins).
  18. sorry maybe misunderstood myquestion. I already know how the rule supposed to look like. My question was more of a why does mod_rewrite have an 'if' part not in a condition but in the 'action' part of a rule. Like how would you describe in human thinking what mod_rewrite is doing? In human logic, you would think this is the case... (no http referer) OR (http referer coming from another site) AND (requesting gif/jpeg/jpg/png) THEN serve another picture to them but instead its seems: (no http referer) OR (http referer coming from another site) THEN check to see if (requesting gif/jpeg/jpg/png) and if thats the case then serve another picture to them thanks if can update.
  19. I am just starting to get back into Mod_Rewrite, I forget the logic behind some stuff, for example lets say we want to stop leechers from taking images. The chained RewriteCond/RewriteRules written in logic as it seems most understand to me: if(no http referer OR http referer coming from another site) AND if( requesting gif/jpeg/jpg/png) then (serve another picture to them (or can set Forbidden so shows up as an X on their site )) But in mod-rewrite language its more like this: RewriteCond if(no http referer) OR RewriteCond if(http referer coming from another site) RewriteRule THEN if( requesting gif/jpeg/jpg/png) Serve another picture (or can set Forbidden) Not sure of the url pattern parameter used in the RewriteRule, could that part be set in the conditions?, so 'if' they are requesting an image seems like a condition to me, but alas mod_rewrite prob doesnt work this way with its trickxies. I guess I am just confused as what the url pattern does in the rewrite part, if its a 'filter' then shouldnt it go in the conditions?
  20. I want to store database connection in session so dont need to reconnect to database on each page but wasnt sure what is best way to do this. My 1st impluse is in my php/session code, is to do something like this: <?php //On session page session_start(); //needed require_once 'MDB2.php'; if(!$_SESSION['uid'])//session not set, get users info and set it in session { $db_host = 'localhost'; $db_user = 'root'; $db_pass = 'password'; $db_name = 'mysql'; $dsn = "mysql://$db_user:$db_pass@unix+$db_host/$db_name"; $mdb2 =& MDB2::connect($dsn); if( !(PEAR::isError($mdb2) )//test a query to generic mysql database just to test if connected { $_SESSION['dbAbstract'] = serialize( $dbAbstract ); } $_SESSION['uid'] = $_SERVER["AUTH_USER"]; } //On php page require_once 'MDB2.php'; include 'session.php'; $dbAbstract = unserialize( $_SESSION['dbAbstract'] ); $testsql = 'SELECT * FROM mysql.help_category'; $result =& $mdb2->query($testsql); if( PEAR::isError($result) ) { echo "<br />Search error..."; die($result->getMessage()); } ?> But what if loses connection, even though session is still alive.
  21. Maybe Postcast Server if u can get it to work for you. i got it to 'work' with a user based site i was testing on my machine but hotmail, yahoo, and others didnt like reciving emails from me. try googling up free smtp server and see what else u find.
  22. I was looking at curl a while back to do paypal stuff, it was a tiny bit confusing. Any simple code examples of curl getting http info through a proxy? my best guess is use the proxy websites form url to curl and supply it the info of the url you want to visit and POST. must be a more elegant way of gettign it through the proxy without using the form on the page. Also what proxies could I trust to return reliable information? is there a list of reliable ones? i use hidmyass_com haha and see they supply a daily list of proxies, i could always use that as my list to randomly pick from.
  23. if I have many thousands of users sign up in 1st day my site goes live, I am worried then spreading them around a day will still be obvious.
  24. I would like to do something like below but am afraid the hosts i am getting info from will ban requests from my url. $url = "www.myspace.com/". getUserName($userID); $content=file_get_contents($url ,FALSE,NULL); //parse html and store some parts in a database. Do you think a site like myspace will give a poop about lil' old me and ban requests from my server? The requests are user initated, and will only parse their webpage. So im not doing anything evil here. Just worried when I run requests everynight, they will see a flood of requests from 1 server and ban the IP. Is there anyway to get http information through various trustable proxies and what functions should i check out?
  25. I would like users on my site to place a random integer onto their homepage and my site will was going to pull their webpage into a php var and then regex if that int is there, if so then they probably have control of at least that webpage on that domain. But I was worried after many http requests from my site, do you think a larger site like myspace etc. would block me? I just want to confirm a user owns any public page that they claim they 'own', not doing anything bad. and dare I ask, ways to get around this? I was thinking somehow use a proxy (never used a proxy to get info, not sure if it would be done through php or server settings, plus wasnt sure which proxys are trustable) but wouldnt a large site like myspace block these too? thanks, Admins: you can move this question if its more appropriate somewhere else on phpfreaks.
×
×
  • 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.