Jump to content

menwn

Members
  • Posts

    36
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

menwn's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello there, The whole point of inner joins is to return rows that have a match in both tables. So in case of not a table having a matching record you will not get anything back for that id. You say that you don't want to use three queries. I suppose you could nest a select count for the MemberAbilities table and check whether you get any result with an if. However it is not clear what exactly is the problem. You might not have or you might have records. How would you know this beforehand? And how much slower is your system using these two inner joins? Or is there any restrictions? For example if you find people in the first table are you required to search in the second? All these decisions can lead you towards a better treatment (provided that this is not it, already) Cheers, menwn
  2. Hi, thanks for the response. So Curl is mostly for services I take it right? Exchanging information between server in the back scene. Well, I thought that there should a be a way to redirect after posting data on behalf of the user. I mean once he has already posted it through a visible form. I don't think that having a button is a good idea. Because it would require from the user to click a button he doesn't see the reason for. After all he just clicked one for the exact purpose of sending his information to the next step. I have a <noscript> tag with a submit button and I let them know why they are seeing this but I definitely use javascript submission as the default. No it even fsocket wouldn't do the trick? Thank you, menwn
  3. Hello all, I have this issue: I have a form with several fields. I need to save to a session variable (in submit page) all of the fields upon submit and then post some of the fields to a https site using a POST request (i.e., doing a header('Location: https://mynewdomain.com/page.cfm?'.$data) won't cut it). Now, I can do it with javascript... a whole bunch of hidden fields in the between page and then auto submit the form to the mynewdomain.com domain using the post method. I am wondering whether there would be a better way for that. I know that Curl does it, with one glitch. When I set the parameter CURLOPT_FOLLOWLOCATION to true it redirects the user BUT it doesn't load any css or javascript from the new page. People say on the web to do a request for each file but I haven't figured out how to do it. Can anyone post an elegant/concrete solution to this problem or should I resort to Javascript? Thanks menwn
  4. Thank you for your help!! By the way the glitch I was talking about ("However it works only if I have at least on record in the table. If no record is there it does not return any results. Why is that?" ) it just the outcome of my not paying attention to detail. I am using doctrine so I was not adding ->select('Sessions s')->leftJoin('s.SessionParticipant'). Doctrine internal if it doesn't see the s in the leftJoin it just translates into select from Sessions,Participants where.... Anyway. Just for future reference to others. Thanks again.
  5. Hi, You mean to say that if I write LEFT JOIN on s.id = u.session_id I have essentially an INNER JOIN? Because I do use LEFT JOIN. The way you have written the query (with the USING clause) I get an error. Is something I didn't get? Can you please elaborate a bit more why the query fails when using the USING clause? Thanks
  6. However it works only if I have at least on record in the table. If no record is there it does not return any results. Why is that?
  7. Thanks... works perfectly with the only change in the left join instead of having regular on s.id = u.session_id. Don't know why though the original, without the change was not working ... Cheers and thank you again!!!
  8. Hello all, currently I have 3 tables. Users, Sessions and SessionsUsers. The SessionsUsers is a table to accommodate the many-to-many relationship that the tables Users and Sessions have. It has two columns sessions_id and users_id However, I have one constrain when I select from the table Sessions. This table has id, session_names, session_capacity and registered. What I want to do is to retrieve only the session_names and ids that have session_capacity greater than the count of each session_id in the SessionsUsers table (i.e., I don't want to fetch sessions that their capacity is already full with users). What I am currently doing is to calculate the capacity via a grouping and counting on the SessionsUsers table by session_id and updating the column registered in the Sessions table at the beginning of the application. This works good enough but I was wondering whether I could select the not full sessions without doing all these updates with a single select statement. I am pretty sure it can be done but I cannot seem to figure out how. Maybe some combination of Joins, groupby and having but still no success. Any help will be greatly appreciated. Cheers, Andreas
  9. Interesting. Yes you are correct and problem was sovled with the only note that the projectOarc directory does not exist. It turned out that I had declared it like that in the vhosts.conf file of XAMPP for the domain I have set up locally but I did not expect such an error to give me redeclaration issues. I would expect the domain not to run at all as it was pointing to a non existent document root (if I went to a test page e.g. www.oarc.dev/test.php it would work correctly for this particular wrong directory root. Maybe your edit about the php.net seems to be to some relevance to my issue but I could pin point it exactly. I mean the require_once in my case was the only that could not understand that the file was the same but since I had XAMPP looking at a non existent directory how the rest of the site (the test.php) run??? Shouldn't it just say directory not found? Especially in an operating system like Mac or Linux.
  10. My advice is to buy the book "core web application development with PHP andh Mysql". Prior to reading this one I was at a complete loss with all the tutorials out there. Also I had tried many other books (not all of them were bad but I liked this one better for some reason). Tutorials will teach you how to do basic stuff fast but I don't think you will learn to code effectively without a good grasp of what is going one with PHP and Mysql. More like they will teach you how to implement (not in the bast ways always) some basic stuff and make things "kinda" work. This book is excellent for a novice and although it is written in 2005 you can still benefit a lot. Btw something that it does not cover is ORM systems like doctrine (after all I think they became big later than 2005) and although they might be advanced for someone just starting to code I would definitely recommend learning one of them as it will BOOST your productivity and quality of code as well as it will help you do more advanced stuff later on. (http://www.doctrine-project.org/) For the time being however don't bother with ORM. Just buy the book (or find it from a friend or whatever) and read it. You don't need to learn it by heart just study through the OOP and MySQL part and try to grasp how PHP works and what you should do in certain occasions (many of them are just what you asked for). As already was said certainly you will not be done in a day. Aim for 3 months (if you have other work to do except for reading and writing code). If you focus you can do it in 1 month, maybe .
  11. Hello all, I am at a complete loss. For the past months I am developing a web site. I have the web site running at my Windows pc at home (where I mainly develop it and run it on Apache 2 with PHP (i think 5.3.x or 5.2.x) ) and I have it running live at the web server. I also have a macbook that I develop the same web site occasionally. I am using XAMPP and php 5.3.1 in this case. I keep the code between my two computers (Mac and Windows) up to the same level using SVN (which runs on a linux machine). What I have done a billion times before and in this case also is having the basic libraries included with require_once in one file called "baseincs.php" and then at each file I only include with require_once this one php file. This has been working for years perfectly and in this particular case has been working for months on the exact same code. Yesterday I wrote some (completely irrelevant, HTML GUI mostly) code on the Windows pc and uploaded it to the SVN. Today being at work I downloaded the SVN update to my mac and out of the sudden I get redeclaration errors on every page (beginning with the index.php). I cannot figure this out. I am positive I have not changed anything(!!!) on the index.php or the baseincs.php. I know that these error will manifest if you use include or require instead of include_once and require_once and you include the same file in multiple places in your code. This has not happened. Here is the code from the baseincs.php require_once 'config.php'; //sets various defined parameters application-wide require_once('session.inc'); require_once('errors.inc'); require_once('bootstrap.php'); require_once('usermanager.inc'); require_once('loginproc.inc'); // sets g_loggedInUID /** * If you don't actually generate any UI in your page, then * just don't instantiate the HtmlGenerator class .... */ require_once('htmlgen.php'); and here is the beginning of the index.php file ob_start(); require_once 'libraries/coreincs.php'; require_once 'libraries/utilitymanager.php'; //global $g_loggedInUID; if($g_loggedInUID !=-1) { $name = Users::fullNameFromUserID($g_loggedInUID); } Finally the code where I get the first error is the session.inc file and it follows <?php //only comments above here /** *=-----------------------------------------------------------= * nuke_session *=-----------------------------------------------------------= * This function completely destroys a session and all of its * data after we have logged a user out of our system. In * addition to destroying the session data, we destroy the session * cookie and also make sure that $_SESSION is unset. */ function nuke_session() { session_destroy(); setcookie(session_name(), '', time() - 3600); $_SESSION[] = array(); } /** * One of these sessions can last 60 minutes */ ini_set('session.gc_maxlifetime', 3600); session_start(); /** * Try to prevent session fixation by ensuring that we created * the session id. */ if (!isset($_SESSION['created'])) { session_regenerate_id(); $_SESSION['created'] = TRUE; } /** * Try to limit the damage from a compromised session id by * saving a hash of the User-Agent: string with another * value. */ if (!isset($_SESSION['user_agent'])) { /** * create a hash user agent and a string to store in session * data and user cookies */ $_SESSION['user_agent'] = md5($_SERVER['HTTP_USER_AGENT'] . USER_AGENT_SALT); setcookie('ag', $_SESSION['user_agent'], 0); } else { /** * verify the user agent matches the session data and * cookies. */ if ($_SESSION['user_agent'] != md5($_SERVER['HTTP_USER_AGENT'] . USER_AGENT_SALT) or (isset($_COOKIE['ag']) and $_COOKIE['ag'] != $_SESSION['user_agent'])) { /** * Possible Security Violation. Tell the user what * happened and refuse to continue. */ throw new SessionCompromisedException(); } } ?> Fatal error: Cannot redeclare nuke_session() (previously declared in /Users/andreass/MySites/projectoarc/oarc/libraries/session.inc:35) in /Users/andreass/MySites/projectOarc/oarc/libraries/session.inc on line 38 As you can see this is not true for session.inc Please note that the exact same code works on my Windows PC. Any help will be much appreciated!!!! Regards, menwn
  12. Thank you for your reply. I want to disable the ability to pass not alphanumeric characters. And this does not help a lot. Up to now I had: preg_match("/[^a-zA-Zα-ωΑ-Ω0-9]/", $text) It works ok but I can pass all letter strings which I want to forbid unless it has at least a digit in it. thanks
  13. Hello all, My question is this. How can one with a regular expression to guarantee that at least on digits exists in a string. Valid Example: ABdafd123 Invalid Example: ABCfgssf Thank you
  14. Hello everyone, I have a form containing a table and I can add table rows in the table using javascript. Each row has a textbox at the beginning that is has as value the number of the row. When I press submit I use post to send the data to a php script. The script has some code like $i=1; while($_POST['SpecificFieldrow'.$i]!="") { switch ($_POST['SpecificFieldrow'.$i]) { case "email": { //do stuff like if(isset($_POST['genericnull'.$i])) { $myform->rulesValid('email'); } break; } //more cases //etc $i++; } The obvious problem with the above code is that if I would like to change the order with which the fields of the rows of the table will be handled by the script I would have to change the numbers in the textbox and have some javascript to change the name in the "SpecificFieldrow".$i (where $i now would be the new number provided by the use) when the number textbox is changed. I would like to avoid this. Is it possible? How can I send the table row by row so as to have code sorting the requests by the numbering fields and enabling the user to choose the order by which the fields will be proccessed? Thank you in advance for any help menwn
  15. Thank you for your help. The php version is 5.1.6 (it is the cetnos rpm). Moreover, the results are more than one row. (it displays the first row). What drives me crazy is that I can fetch the whole recordset if I display the results in the page that executes $result = $conn->Execute($query); It fetches the whole recordset. The problem is when I use the $_SESSION variable.
×
×
  • 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.