-
Posts
4,704 -
Joined
-
Last visited
-
Days Won
179
Everything posted by kicken
-
Note: This is a fairly dumbed-down explanation, hopefully for easy understanding The find_all method queries the database and gets back as a result an array of every row that exist in the database. For every row that it gets back from the database, it runs essentially $obj = new Photograph; and then sets all the properties in the Photograph class to the corresponding column from the database row. Each time it makes a new photograph object, it sticks the object into a array which eventually is the return value for find_all. So your code gets back an array of objects, each of those objects is a new separate instance of the Photograph class. Hopefully that helps explain things. If not you might need to try and read more about how classes and objects work in general.
-
Someone is posting the form and bypassing the JS validation. Maybe they have JS disabled. Maybe it's a bot that just fills in random values. Always validate your data server-side with PHP. Users cannot bypass that like they can Javascript.
-
MsSql connection to dedicated server assistance needed
kicken replied to vbcoach's topic in PHP Coding Help
Changing the server from localhost to the IP should be all you need. Make sure the username/password/dbname are the same and didn't get changed (or update your settings accordingly). If it won't connect you'll need to post what the error your getting is (or perhaps just email your host for support). -
At the very least, you could install something like ConnectBot in order to SSH into a remote box and do your development that way. I kind of doubt you'd be able to setup a local environment w/ php, mysql and apache. I'd guess the best you'd be able to get is to install a decent editor and ftp client to upload files, and would have to rely on an external server to host apache/php/mysql. I've never looked into such a thing on android though. I've only got my phone and trying to do any dev work on it would be a nightmare (small screen, crappy keyboard).
-
Without some kind of authentication mechanism there is not much you can do. Even with authentication there isn't a whole lot you can do. About the most you could do is make it more difficult for someone to grab your data by using something like a token system. When a user loads up your site you generate a random token value and embed that in the page. Then when you request data you pass that token back and check it against a list of valid tokens. All a user would have to do to defeat that though is request your page first to obtain the token, then request your data. It just makes the process ever so slightly more difficult/annoying.
-
You can't pass parameters like that using include. The value you give to include is the name of a file, not a URL (in this case) so URL style parameters are not allowed. An included file has access to all the variables defined in the current scope so to pass those variables you could just do: $_GET['a'] = 'newsnew'; $_GET['show'] = 9; $_GET['f']= '2,99'; include('community/ssi.php'); The above assumes ssi.php is expecting $_GET['a'], etc. If it expects just $a, etc then set those variables instead.
-
How to get OUT parameter from mysql stored procedure using ZF
kicken replied to dungpt29's topic in Frameworks
You should just post how you ended up solving the issue, rather than wait for someone else to ask how. Could be several months before someone posts a reply asking how and then you wont be around to answer them. Post the solution now and save them and yourself the trouble. -
E_Warning and paths revealed...
kicken replied to robertboyl's topic in PHP Installation and Configuration
There is something wrong with your PHP setup or configuration if it is still showing errors on screen even with display_errors=off. Without more details though (full details of phpinfo() for example) it's hard to say what is going on. -
Incrementing the tries variable does no good, because every time the script is run (each page load) all variables are re-initialized. Values are not carried over from page to page (so $tries always starts at 1). In order for a variable to be maintained from page to page, you need to store it in either a session or a cookie.
-
How to get OUT parameter from mysql stored procedure using ZF
kicken replied to dungpt29's topic in Frameworks
I've not used Zend or done much with Mysql stored procedures, but using PDO/SQL Server the way you would do it is to bindParam the value for the out parameter also. Such as: $sql = "call sp_insert_newnumber(:v_in_number, :v_out_number);" $stmt = new Zend_Db_Statement_Pdo($db,); $stmt->bindParam(":v_in_number", $param1, PDO::PARAM_INT); $stmt->bindParam(":v_out_number", $param2, PDO::PARAM_INT, 11); $stmt->execute(); After you execute it, $param2 would contain the value of the output parameter. You could try something similar and see if it works the same when using mysql. -
Sure, you could write code to query a WordPress DB and pull out the info you want. You just have to figure out what information you need and from which tables you get it.
-
This bit: IF(status = 'open', 1, 0) AS open, IF(status = 'closed', 1, 0) AS closed, IF(status = 'cancelled', 1, 0) AS cancelled would translate as: CASE WHEN status='open' THEN 1 ELSE 0 END as open, CASE WHEN status='closed' THEN 1 ELSE 0 END as closed, CASE WHEN status='cancelled' THEN 1 ELSE 0 END as cancelled Then you have three separate 1/0 columns, one for each status. Same as the original query.
-
Copying files from one hard drive to another
kicken replied to The Little Guy's topic in Miscellaneous
The drive should show up, assuming it is hooked up and running. If it doesn't, maybe there is some bios option preventing it from showing up, you could check there and see if anything seems relevant. If none of that works, you'll need to do as others have suggested and get some kind of enclosure you can put the drive into which then plugs into your USB port. Either that to try and get the windows 7 drive to boot (or use a linux live cd) and copy the files off to some other computer or external media. -
Copying files from one hard drive to another
kicken replied to The Little Guy's topic in Miscellaneous
You don't want to try and boot from the second drive, just access it from within windows. Boot up windows 8 and open up Computer management (in win explorer, r-click Computer and select Manage). Open the Disk Management area. In there you should see your windows 7 hard drive. Select the partition you want to access and right-click on it. There should be an option that will allow you to map it to a drive letter. Once you do that you can just go into the drive via windows explorer and access the files. -
It could be that your sites are somehow generating some sort of error message under the new PHP configuration which it was not previously (ie maybe an E_NOTICE or E_STRICT error). I don't really see anything off hand in the code provided that would cause such a message but it remains a possibility. Create another simple that that contains only: <?php phpinfo(); ?>Save it as phpinfo.php in your web root and then load it up. See if you get the same error or if you get the PHP Information page back. If that page works, I'd lean toward an error in your scripts. If that page doesn't work, then it is likely a PHP configuration issue which your host will need to look at. If you have access to PHP from the command line, then try running your page using this command, and see if any errors show up: php -d error_reporting=E_ALL /home/snodart/public_html/index.php
-
Rounded corners are a HTML/CSS thing, not PHP. Some googling will get you a bunch of howto's.
-
You can't just do a simple while(fgets()) loop when reading your socket. fgets() will block if there is no data to be read meaning your script will just halt on that first loop waiting for more data when what you really need to do is quit that loop and send the next command. To do that your best bet is to put the socket connection into non-blocking mode with stream_set_blocking and change your loop to correctly determine if fgets returned data or not. If there is no data available I believe it would return false, but a little testing should figure that out for sure. There's actually a fair amount to consider when dealing with two-way socket communication and ensuring you handle the data properly. You might be able to hack together something that works for your needs but you may be better off doing some googleing to try and find a pre-written library to do what you want.
-
Major Math Variable screweup & completely lost myself
kicken replied to Angeleyezz's topic in PHP Coding Help
You need to have two different subtotal values. One that totals the taxable items, and one that totals the non taxable items. Then to get the final total you just add them together along with the appropriate tax. // Begin While Loop of invoice records $taxableSubtotal = $nontaxableSubtotal = 0; while($row = mysql_fetch_array($query_invoice_entries)) { $quantity = $row['quantity']; $sku_number = $row['sku_number']; $location = $row['location']; $price_each = $row['price_each']; $sku_description = $row['sku_description']; $sku_taxable = $row['sku_taxable']; $price = $quantity*$price_each; if ($sku_taxable==1){ $taxableSubtotal = $price; } else { $nontaxableSubtotal = $price; } //... } $finalTotal = $taxableSubtotal*$taxRate + $nontaxableSubtotal; -
echo '<script type="text/javascript">alert("Registration number: '.$regnum.' already exists");history.back();</script>'; Just concatenate it into the output string like you would any other variable. The fact that it is going into a JS string doesn't really make that much of a difference.
-
Trying to fire off an ajax request every second (or even every two seconds) is not really the best of ideas. It puts a lot of extra load on the server and requires a pretty fast connection to even happen. Ideally you should find a way update the page without so many requests. Since your once-per-second item seems to just be a clock value, rather than make an ajax request every second, just have JS update the clock on it's own (get current time, add a second, update display). You can run an ajax request once a minute or so the keep the clock in sync with the server if desired/necessary.
-
You shouldn't have a comma after the last array item, however that would not cause the error you are getting. Your error most likely comes from some other bit of code above that section, you need to post more of the code, or look higher. Just because PHP says an error is on line XX does not mean that is where the error actually is. That is just how far PHP managed to get before the code stopped making sense. Some problems such as forgetting quotes or brackets can result in an error not being reported until much later in the code than where your problem actually is.
-
Is it possible to find a previous session if cookie has been deleted?
kicken replied to eldan88's topic in PHP Coding Help
You use session_start either way. If you did not set your own session handler using session_set_save_handler then you most likely are using file-based sessions. -
Is it possible to find a previous session if cookie has been deleted?
kicken replied to eldan88's topic in PHP Coding Help
With traditional file-based sessions you could get the session_save_path directory and scan through the files searching for some particular string. If you find the string, then the session ID is in the name of the file, just extract it and restore it (using session_id prior to session_start). If you are using some other session handler (such as memcache or mysql) you'll need to figure out something else out by looking into how the data is actually saved. -
No, not really. The api's and methodologies differ a bit too much for something like that. For example there is no $db->real_escape_string to replace mysql_real_escape_string. There is $db->quote which is similar, but the proper method to use is prepared statements where to completely remove the variables from your query text and use placeholders instead. Read the pages I linked above on prepare and execute for details and examples.