cpd
-
Posts
883 -
Joined
-
Last visited
-
Days Won
5
Posts posted by cpd
-
-
No, the PHP Compiler will optimise your code. The reference is merely a means of creating another variable for the same content; a reference. Its not a pointer and "they are not actual memory addresses" - http://www.php.net/manual/en/language.references.whatare.php
Passing by reference allows you to directly manipulate content within a function/method of a variable defined outside the scope of the function/method.
-
phpMyAdmin is a third party tool. Whenever you're messing with your database, see if you can access it directly via command prompt (as you did) and if not, then you know its the server - and vice versa.
The character restriction is something put on by the phpMyAdmin developers not the MySQL Server. You can probably change the settings somewhere, just do a bit of research.
-
Firstly check the output of your PHP file by going to it in the browser. If that checks out, you can assume its your AJAX that's screwing up.
Try testing if the success/error callbacks are triggered using an alert().
-
You can encode it either way, the encoding is irrelevant, just make a decision and stick with it.
Regarding your for loop, you can just use
result["errors"].length
. I think you need to start researching as you're firing questions off without thinking about things yourself. -
$errors = array("Error 1", "Error 2", "Error 3"); $success = array("Success message"); $output = array("errors" => $errors, "success" => $success); echo json_encode($output);
-
if(errors.length > 0) { // XHR for errors page } else { // XHR for success page }
-
Now I can see your error. Line 11 should be
errors = new Array();
not lower-case "a". -
What's "studentArray" its not defined anywhere. You definitely logged the result on the first line of your success function?
-
You'll need to cycle through every file every time in that case.
Alternatively, if you can store the last file used and you know how the file names increment, you can implement an algorithm to "guess" the next file name and search for it. If that fails you can fallback to parsing every file name.
If you can be sure the file name will end the same as your example then go with the http://php.net/ftp_rawlist function and search for the most recent file. This method depends on the file name though, and assumes the file naming convention will be continuous.
-
If you don't assign an index, php starts the indexing at 0 anyway so there's no need to explicitly set it.
Answering your question directly: you can do what you're asking no problem but I'd keep the questions and answers together. They're related and shouldn't really be separated.
Take a look at http://uk3.php.net/manual/en/ref.filesystem.php for file system functions. More specifically
fopen($file)
,fgets($handle)
andfclose($handle)
.A, what I consider as better, alternative is to create an XML model storing your data in that. You can then use the DOMDocument() object to parse the data for you and easily cycle through all your questions and answers. Food for thought.
-
You can use the ftp functions (http://php.net/ftp) to list the files in the current working directory. You'd then be able to parse the file names and create some sort of order. Finally, you can retrieve each file in that order.
Similarly, you could retrieve the last modified time using http://php.net/ftp_mdtm and order the files using that. The last step would be the same.
Why do you want to do this?
-
Are you using objects or sticking with arrays? Also, why do you explicitly define an index for the first element in each answer array but not the other answers?
-
The full URL syntax can be found at http://en.wikipedia.org/wiki/Uniform_resource_locator
-
So you can successfully log in to the server using the command prompt? But can't log in through, what I assume is, phpMyAdmin?
-
You don't use back ticks for string values, it should be apostrophes. You also don't need the semicolon on the end.
-
Log in the console the result before you do anything and I suggest you test it in Chrome as it'll show you in detail what it contains.
-
RTM http://uk1.php.net/session_Register.
session_register
is deprecated as of 5.3 and removed as of 5.4. Assuming you're PHP version is up to date you shouldn't be using it.Set a session variable using the
$_SESSION
super global and test for it on pages requiring authentication.Why are you stripping slashes from the password as well? You should be storing them in an encrypted form for added security.
-
Not necessarily, the response served up by the server is a 406, but in the process of handling the 406 it found a 404 as the error document couldn't be found. A simple visulisation:
Client Server File System Request |---------------------->| | | | Handle Request | | | 406 | | | Get error document | | |----------------------->| | | | | | Document not found | | |<-----------------------| | 406 with 404 error | | |<----------------------| |
That said, PHP or something else could just be setting the HTTP status code and sending the response.
-
Show us what you have and lets try and address your problems. No-one is going to write the code for you so forget about it.
-
If you want to develop locally, which is generally what I do, you'll need to install a web server, PHP and potentially MySQL.
Just get the latest releases for each; each can be found at their respective home sites. Alternatively, you can install a package such as WAMP or XAMPP although they often take a while to update so you wont necessarily have the most recent version.
-
The server has experienced a 406 error and tried to handle it using some sort of error document but couldn't find the error document and has informed you of this.
406 Not Acceptable
The resource identified by the request is only capable of generating
response entities which have content characteristics not acceptable
according to the accept headers sent in the request.- RFC2616 HTTP/1.1, pp 67. Available at: https://tools.ietf.org/html/rfc2616#page-67
-
What happens if the user changes their username? If username is unique and will never change, why don't you use it as the primary key?
What have you attempted yourself? We're not about to write the code for you which is why your post implies you think?
-
No idea what you mean for the last one.
I appreciate your new but this applies to life. Go and do your own research and put the effort in yourself and you'll learn a lot more. Come back with a specific problem and we can assist.
If you want to know what a specific PHP function does, go to http://php.net/function_name where function_name is any function or even something similar and it'll explain everything.
To get you started on your first task:
Lots of options and ways you can do it. Each one will essentially get you to 1) Open the file, 2) Loop through its contents populating the dropdown.
-
Using PHP and XML for localization
in PHP Coding Help
Posted
Its possible, to what standard I don't know. You'd have to find a pretty good translation script/system. Google Translate is considered naff by professional translation companies but it's down to your requirements as to what is acceptable.
I dislike CodeIgniter!