Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. We have had this question in the past, and afaik, php-dio is the only way to get read/write serial port communication working on windows. Read the manual page carefully, as there are version requirements: http://us2.php.net/manual/en/book.dio.php This article has a wrapper and working implementation you can use as a basis for your project: http://blog.950buy.com/article/php-use-rs232-serial-communication-to-send-file/
  2. MarijanT: Thanks for letting us know you've found the forum as a good resource for you in the past. The purpose of this forum is to help people learn to code php. We aren't designed, nor do we want to be an alternative to google, hotscripts, or other places that help people find pre-written scripts that they can use.
  3. Well it depends on how you look at it. To php the function call is the shell_exec. It is completing. If the cp command executes but doesn't execute in the way you want, to php it is still executing. There are also a number of php.ini settings that can stop operating system commands from running, as well as operating system permissions, and environment issues that can effect a script running. I don't think that is the source of your problem but you should read about them and check against your configuration just to be sure: http://us3.php.net/manual/en/ini.sect.safe-mode.php The way php is being used is another issue. How these external calls work or not is highly dependent on the operating system, the webserver and the way it's been configured. There's just way too much involved for me to summarize. Since these commands seem to work for you from the shell an quick way around your problem might be to make a bash script that takes parameters, unit test that and call the bash script in your shell_exec. You can in your script redirect std output and stderr to a file. In fact you might experiment with that just with the current command you are running. I did note that you are using spaces in directory names -- not a great idea, since they add more things that could go wrong as Thorpe pointed out. For example, one of your paths -- I can't remember which one, has a space in it.
  4. Things that don't produce an error don't go into the error log.
  5. Try this: $cmd = "cp -rf /var/www/http/test.com/products/{$fordir['fordir']}/{$category['category']}/{$_POST['id']} /home/n/Documents/test.com codebase"; echo "Command is: $cmd "; $retval = shell_exec($cmd); echo $retval;
  6. I pasted you code to use to get the return value of the command. $retval = `command` is the same as $retval = shell_exec(command). I want you to run that so we can see if there's output.
  7. GREAT idea, but didn't work. What about the shell_exec output?
  8. FYI: Instead of: system ("cp -rf /var/www/http/test.com/products/".$fordir['fordir']."/".$category['category']."/".$_POST['id']." /home/n/Documents/test.com\ codebase"); $retval = `cp -rf /var/www/http/test.com/products/".$fordir['fordir']."/".$category['category']."/".$_POST['id']." /home/n/Documents/test.com\ codebase`; echo "Result: $retval"; One thing to look at would be using the path to cp which is probably /bin/cp. In your shell try "which cp".
  9. I'm glad you honed in on the question of the CompanyRep parent table. I agree that it is optional, but I didn't want to get into a long thread about alternative designs. Depending on your application and how the keys are setup it could be beneficial or not depending on the flow of your application. For example, one thing it allows is an intermediate state where the application has identified that a person is a company rep, but you don't yet know what if any states they are representing. All things considered, I think your design is solid for this application.
  10. No, you never want to make seperate tables for something like this. You should have a state table with 1 row per state. Have a companyRep table that relates Reps to companies. I'm going to assume that Company And Rep each has an integer primary key auto_increment on it, named "{table}_id". Your CompanyRep table would be: CompanyRep -------------------------- company_id (pk) rep_id (pk) Now Have an additional table named CompanyRepState that simply indicates the states that a particular "CompanyRep" can cover. CompanyRepState ----------------------- company_id (PK) rep_id (PK) state_code (PK) For the CompanyRepState table, you will add a unique index on company_id, state_code. This index will only allow one row to be in the table for any company/state combination and will enforce your business rule.
  11. As you say, it is your code, do you understand it? The reason he told you to echo out the sql statement is because you are building it with code. What is important is the final result. I will save you further consternation, by asking this question: UPDATE mytable SET name = 'Freedom' WHERE name = 'Freedom' Now this is equivalent to what your query is doing. Do you see the problem now?
  12. Yes, as Ninjeh suggested there is a get of http://www.youramazingproducts.com:8880/javascript/promo-flags.js.php occurring.
  13. Please don't take my answer as anything other than my attempt to answer the questions you posed, even if it seems there was an implication there. Most hosted sites are running on linux, and as you say there are differences between linux and windows setup. That is one of the reasons I keep pointing people to sun (now oracle) virtualbox, which is a great free virtualization tool. I personally use windows for my workstation, so this is something I do myself. Also, the mysql administration items I pointed out, are the same across platforms -- setting up a database, grant/creating a user and giving it permissions to commands and objects is the same no matter what platform you're running it on. It's all sql
  14. Do you literally have those quote characters in your code? That will not work. Also that is not valid php. You need a semicolon to end the statement. echo " Hello World!"; ?>
  15. I'm not sure why it's important this be generic. // offsets is an array of the offsets you want to remove. // In your example, you would want the $offsets to be 9, 10 function filter_keys(&$array, $offsets) { $count = 1; foreach ($array as $key) { foreach ($offsets as $offset) { if ($count % $offset == 0) { unset($array[$count - 1]); } } $count++; } } // You'd call like this: filter_keys($array, array(9, 10));
  16. In my experience we're far friendlier than most community sites. I also can't agree that people need the obvious pointed out, but I will agree that even experienced developers miss the obvious. The difference is effort, and in this case the OP even admitted he didn't put in any effort. Well I think that there is still a demand for windows desktop apps, but as for database driven "enterprise" apps, for lack of a better term -- the kind of apps that might in the past have been written in a windows 4gl like powerbuilder, centura or Visual Basic, you would have a hard time convincing someone that approach makes sense these days. Everyone wants a web ui now. Yes pdo is using the interbase.dll, which is in turn using the firebird client libraries. Pretty much every rdbms takes the same approach. PDO is an excellent interface, and I think your plan on using ZF and its zend_db class is a smart one. I think you nailed it. In my experience people rarely port applications from one database to another. Database portability is highly over rated, and often glosses over details in how different databases facilitate commonly helpful features. If there's something in a database that is really helpful, not to mention highly performant, I want to use that feature, rather than some dumbed down feature with gotchas and lousy performance, all in the name of retaining database ui independence for the magical day when years of data get ported to some other database engine for reasons unknown. With that said the use of an orm (which is basically what you're getting with zend_db and zend_db_table, albeit a relatively minimal one) is another way of getting a pretty good layer of db independence. At any rate, thanks for providing your experience with Firebird and PHP. You are definately in the minority, but clearly for good reason, and Firebird is an excellent option for people on the windows platform that doesn't seem to be considered near as much as it probably should for people with a commitment to the windows platform.
  17. The dot is because you are using a ul, and you have a li in it, but you have not suppressed the default list style which you can do by styling the li items with: list-style: none; As for you key handling, you can attach an event handler to the document, and thanks to event bubbling, keypress events will bubble up to it. JQuery has a .keypress() method as an example, with some information about how it facilitates determing which key was pressed here: http://api.jquery.com/keypress/
  18. I'll try and answer your questions as I understand them, by demystifying a few things. In really general terms operatiions groups tend to break down roles as: -network engineers/telecom -system administration -security When you have a hosted server, you are paying for the hosting company to provide all of these services in some fashion, whether that is shared hosting, vps or dedicated server. Shared hosting is not providing you more service for less money -- they are simply maximizing their investment by loading the most customers possible on the available infrastructure. When you talk about administration you seem to be talking purely about the system administration aspect. I focus on linux system administration. There are good reasons to learn at least a modicum of sysadmin skills as a developer, because your application is going to be running on the os, and there are routine issues related to that like file system permissions and ownership, or cron that are tools that you really need to understand. You also are well served to understand some networking basics, and be able to setup lamp. There really is very little excuse not to explore sysadmin given the availability of cheap hosting, and cheap or even free virtualization. For example, anyone with a relatively recent workstation or laptop can get a copy of virtualbox, download an iso for centos or ubuntu or debian and have their own playground where they can install and configure things and learn in a completely safe environment. Here's an article series I wrote that walks you through the process and here's another one for Ubuntu. If you look through those, you should see that there is nothing magical about setting up LAMP. These are things you should try and do yourself, and I will guarantee you that it will be a great learning experience and increase your confidence as a developer because you will learn how to explore a system and figure out how things are configured, which is a skill that comes in handy especially where problems arise. So basically you can easily have your own private development network running on your own computer where you can practice, explore, and develop your code, using the same server operating system your client is running on. Let's demystify for a moment what a shared host is providing. They run the same os's, and the same software that you can, only they typically are running it with software that has been configured so that you can do certain sysadmin tasks using the gui. Some people see this is either a convenience or a necessity, but the reality is that very few businesses ever use the things in cpanel for anything other than adding a new company email address. For more complicated tasks like adding a subdomain with users, databases and associated users, the customer is not doing that -- someone they are paying is doing it through cpanel. I don't use cpanel unless it's already part of the equation, and the reason is simple: I don't need it, and it uses resources. It requires disk space, and the apache processes and databases it utilizes have to come off the top of what is available. The first constraint you typically hit in a lamp app is the availability of memory. Everything runs better when there is lots of memory available. I don't see it as a benefit to take a chunk of that available memory and have to give it to cpanel purely so that once very 6 months someone needs to login for 5 minutes and do things that I can easily do with command line utilities in less time. However, many shared and dedicated hosts offer the ability to have all the same software they use. These are often billed as reseller accounts. If you want to pay for that they will provide it for you. There are also plenty of solid alternatives like Webmin that do most if not all the things that cpanel does: http://www.squidoo.com/10-free-cpanel-alternatives There have been times I've setup a vps server for someone, and added webmin and usermin to give them the ability to do a few routine tasks they require. Once you understand linux itself and how a distro package manager works, and how applications tend to be laid out and how they work, you're in a good position to start poking around cpanel and seeing how it works and what conventions it uses. None of it is magic. Once you get start on this path it's a natural progression to learn about apache, and mysql administration. There are plenty of books and tutorials out there, and the main thing to realize about mysql is that like most all rdbms's you interface to it with sql commands. Once you go into the mysql client and create a new database, create a new user and grant the user permissions to the database, I'm sure you'll realize that the value of cpanel to do that for you is pretty minimal. To conclude, there are many different hosting companies, with different divisions and different product lines. You can find all sorts of different packages of services out there. It really all comes down to what the customer wants, and how much they are willing to pay. The bottom line is: shared hosting is a cut rate entry level service. Some companies do that better than others, but it's primarily designed to get people who want to host a few simple web pages. This works for the hosting companies because most of these websites get no traffic, and consume no resources. They get 16 page views a week. What support is the customer actually getting? Is there site backed up completely and accurately for free? If you install an application do they provide support on that application? Who exactly do you get when you call customer support? What actually happens if your site gets wildly successful, or they perceive you to become a resource hog on the server? The perception that shared hosting is intrinsically better supported hosting, is just plain wrong. When people spend more on a single expensed lunch for employees than they pay for their web presence for a year, that should indicate that the customer has not been properly educated, or simply doesn't care about their web presence. If it's public facing, they may care when some kid who setup a phpbb for his friends, gets exploited, and turned into a spam bot, and his host (which shares the same IP address as your customer) ends up on an RBL list, and all your email now gets spam blocked and your customers site is getting filtered by Norton 360.
  19. For a beginner, CI or CakePHP is going to be easier. However, the question is whether you want to invest in learning 2 antiquated long in the tooth frameworks purely because they are easy to learn, or whether you want to learn the state of the art. There is going to be a steep learning curve regardless, and typically you're learning the framework because you want to actually build applications with it. The two most advanced php frameworks right now are Zend Framework and Symfony. In my opinion you should look at them both. Again for a beginner, ZF is both a framework and a library, and because it has so many different options, people often find it confusing to get started with. If you're using mysql, many people pair it with an orm library like doctrine. Where this is one of the fundamental bundled libraries with Symfony, with ZF you have to figure out how to inegrate the two, or you use zend_db. As a beginner, I'd probably suggest you start with symfony, as it doesn't expect you to understand how to put all the pieces of the framework together. It has application tutorials that walk you through building a real world application, so if you're a learn by example type person, you'll probably find it's easier to get going with it.
  20. I don't need phpMyAdmin to do a grant and neither do you. With that said the user may not have the grant permission for their own database. Regardless, phpMyadmin does not use some magic interface -- it issues a GRANT statement. I'm not sure what you mean by merge. If you mean that you moved all the tables over into one database, that sounds like a good solution. There are plenty of situations where that would not have worked. What if the two systems had tables with the same name? In my experience part of dealing with customers is at times educating them about hosting. A bargain basement shared host is no bargain, and unless you're working for less than you can make flipping burgers, they are paying you a lot more to work on their problems than they're paying for hosting, and you would be doing them a favor to let them know that they are better off with either a vps or a dedicated host from a reputable hosting company. I've seen numerous cases of people who have a minimal site that is taking 5x longer than it should to serve a page due to being on an oversubscribed shared host, or seen their site coming up as server not found due to lousy dns servers. If it's a business worth anything, I can't imagine why they wouldn't want to pay a little bit extra to insure their customers can actually reach their site. If the people they are paying to work on their site can't do their job efficiently, there is no economy to that. I don't work on any site where I don't have shell access. Truthfully, you seem way too please with yourself for having to work around a crappy shared hosting company. There is no victory in that, and it also seems like you could learn a good deal more about database administration, if you're going to be working on database driven applications.
  21. I don't like questions like this, because they suggest that the answer to an unreasonable constraint is to accept the constraint, rather than take the common sense approach and deal with the removal of the unreasonable constraint. You can reference multiple db's in the same query using dbname.table. The only problem you have is access. The answer here is to go to your client, and have them get support from the hosting company to GRANT access for userA (if that's the user you'll be using) to userB. Before you assume you actually need to do that you should see if userB is able to GRANT access to its tables to userA. Otherwise, have the client get the support they require so you can actually accomplish the goal they are paying you to accomplish in a reasonable and efficient manner.
  22. What do you mean by open? Are you accessing them through http://localhost/?
  23. Simply read about $_COOKIE and setcookie Something like this: if (isset($_COOKIE['visited']) { header ('location: index.php'); exit(); } else { setcookie('visited', 1, time() + 31536000); header ('location: welcome.php'); exit(); }
×
×
  • 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.