Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. @thegweb Topics merged. Please do not post multiple topics for the same question. Also please note when posting code to wrap it inside tags or press the <> button in the editor
  2. Set the CURLOPT_RETURNTRANSFER option to true $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_HEADER,FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // set to true to have curl return the response, rather than output it directly // $response will now contain the sms confirmation code $response = curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch);
  3. What is line 55 of user.php? This will be why your javascript code cannot parse the json from the response because both the php error message and json encoded array are being returned.
  4. You need to use echo before highlight_string if you want to output the source code with syntax highlighting echo highlight_string($SourceFile);
  5. Could you post the errors you are getting. Also could you tell us what is $user->data() is returning? (use print_r or var_dump to see contents).
  6. Because your links are wrong <a href="ShowSourceCode.php"? source_file=SimiliarNames">[View the Source Code]</a> ... <a href="ShowSourceCode.php"?source_file=EmbeddedWords">[View the Source Code]</a> Your links will not be passing the querystring to ShowSourceCode.php, it needs to be within the href attribute. <a href="ShowSourceCode.php?source_file=SimiliarNames.php">[View the Source Code]</a> ... <a href="ShowSourceCode.php?source_file=EmbeddedWords.php">[View the Source Code]</a>
  7. There is not set support length. MySQL improved may look similar to mysql_functions but it is not. Do not come under the illusion all you need to do is add an 'i' after mysql in the function names. There are differences, for example some mysql_() functions took the connection resource as an optional argument. However the mysqli equivalent functions now require it and is usually the first argument. You should study the mysqli documentation for the differences. Then maybe stick with procedural programming if you are not used to OOP.
  8. benanamen is referring to the use of mysql_() functions. These functions have been deprecated (no longer supported) for a while and is to be removed completely in the upcoming release of PHP7. You have two options you can either use PDO or MySQLi to connect to your mysql database. Now the other problem with your code is not very good. You are not using OOP correctly. Globals has absolutely no use in OOP (or in procedural code to be honest). If a method requires external value(s) in order to perform the task you should be passing those value(s) as arguments, not defining them as global If a object needs to use a value within another method of the same object then you should be saving it as a property. You will use $this to access the objects properties in the other methods of the object.
  9. As you have named your file field as filename[<?php echo $row['student_id'] ?>] You need to add the student id to the $_FILES array $file = $_FILES['filename']['name'][$ids]; $file_loc = $_FILES['filename']['tmp_name'][$ids]; $file_size = $_FILES['filename']['size'][$ids]; $file_type = $_FILES['filename']['type'][$ids]; Next make sure the studentdocument/ directory exists and is in the same directory as your php file that is processing the upload. You may also need to set the necessary file permissions to allow PHP to write that directory too.
  10. You can not customize the javascript prompt. However you can create your own custom popup windows the modern way is to create a modal window I assume you mean the file upload. If so then please read the following chapter Handling file uploads in the php manual it explains how PHP handles file uploads. When saving the uploaded file to the database you should only be storing the filename (or path to the file). The file itself should stored on the servers file system. Why is there two different fields named filename?
  11. Yes you can however you need to write the switch statement differently. Like so // matches which 'case' evaluates to true switch(true) { case($emission <= 100 ): $cssClass = "emission_a"; break; case($emission <= 120 ): $cssClass = "emission_b"; break; case($emission <= 150 ): $cssClass = "emission_c"; break; case($emission <= 165 ): $cssClass = "emission_d"; break; case($emission <= 185 ): $cssClass = "emission_e"; break; default: $cssClass = "emission_g"; break; } }
  12. I don't understand what do you mean by that?
  13. It is no good just dumping the code. How are supposed to help if do not explain what it is you are trying to do?
  14. Yes, because its command line only. Command Line/Terminal is plain text only. As I mentioned earlier to have that code display the form you need to run your code from PHP enabled HTTP server. You then browser to your php file in your browser to run the code.
  15. What? Where you getting fd from This is what I said
  16. Your <table id="projectOptions"> ... </table> needs to be wrapped within <td></td> tags.
  17. Look at the four lines of code. What line do you think is displaying the number?
  18. $myname needs to be $myName
  19. Yes with the highlighted corrections in red That'll be pretty much the same code I posted earlier and what Psycho had also posted
  20. To print a random number from $myName you can do $myName = "Alison"; $randomPosition = rand(0, 5); echo "Random letter from $myName: " . substr($myName, $randomPosition, 1); // or as simply as echo "Random letter from $myName: " . $myname[$randomPosition];
  21. Oh the grade id in your screenshot is the $row['student_id'] value. In that case change stud_ids = name.match(/\d+/)[0]; to be stud_ids = name.match(/\[(.*)\]/)[1];
  22. Remove the onclick="prompt" from your radio buttons you don't need that now. The javascript should either be placed between the <head></head> tags or before the closing </body> tag
  23. Make sure you are loading Jquery into your page before that code Edit On the last line before </script> remove the characters in red })(); Change $('input[type=radio]').on('click', function(e) { ... code ... }); to be $('input[type=radio]').on('click', function(e) { // if this radio button value is not Passed if($(this).val() != "Passed") { ... code ... } });
  24. You need to name your remarks and filename fields with the same student id as your radio buttons <td><input type="text" name="remarks[<?php echo $row['student_id'] ?>]" /></td> <td><input type="text" name="filename[<?php echo $row['student_id'] ?>]" /></td> Now when the user clicks the radio button you can need to only populate the remarks and filename textfields that use the same student id in thename. To handle this I would use Jquery <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script type="text/javascript"> $(function() { $('input[type=radio]').on('click', function(e) { // get the radio button name attribute value for the radio button that was clicked on name = $(this).attr('name'); // extract the student id from from the radio button name student_id = name.match(/\d+/)[0]; // target the remarks and filename textfields that are associated with the same student id remarksField = $('input[name="remarks['+student_id+']"]'); filenameField = $('input[name="filename['+student_id+']"]'); // display remark prompt and populate the prompt with the existing value enteredRemark = prompt('Enter your remark', remarksField.val()); // display filename prompt and populate the prompt with the existing value enteredFilename = prompt('Enter your filename', filenameField.val()); // apply the values for the remarks and filename textfields remarksField.val(enteredRemark); filenameField.val(enteredFilename); }); })(); </script> See Live Demo
  25. Well if you are going to display the current pad_count before the update then yes you'll still need to the select query.
×
×
  • 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.