Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Nope this was a change in PHP5.5.
  2. The text between the square brackets are called the array keys. The text after the => is the value assigned to that key. To get a value from an array you use this syntax $array['key'] So if you want to get the area_code value you would use $xml['area_name'] With objects the text in the square brakes is the property name. The text after the => is the value assigned to that property. To get the value from an object you use this syntax $object->property So if you want to get the area_name value you would use $xml->area_name; Note the value assigned to the bounding_box key is an object. So to get those values you use this syntax $array['key']->property. For example to get the latitude_max value you would use this syntax $xml['bounding_box']->latitude_max.
  3. It will if you use a for(each)/while loop?
  4. Tested your code and it is error free for me.
  5. If you are seeing the PHP code then either your server is not configured correctly, file does not end in .php extension or you are loading the file directly into the browser (address bar starts with file://). Can you tell use how you are testing the code? The version of HTML you use has no effect on PHP.
  6. $row['category'] is used in your query to return records from your table where the id matches. Problem is $row['category'] is not populating the query with a value as shown in the error message (query highlighted in red) Wherw is $row['category'] defined? Are you sure that is the correct variable to use in the query?
  7. 1) Change the foreach $linesOf5 loop to this. foreach($LinesOf5 as $lines) { // remove the # from the start/end of each line $record = array_map(function($v) { return trim($v, '#'); }, $lines); // add record to records array $records[] = $record; } 2) You can do something like this // connect to mysql $mysqli = new mysqli('localhost', 'username', 'password', 'database'); // use a prepared query to insert data into database /* NOTE: You will need to change: - tableName to the name of your table - ...listTableColumnsHere... with a list of your column names eg: description, breed, size, length, weight */ $stmt = $mysqli->prepare('INSERT INTO tableName (...listTableColumnsHere...) VALUES(?, ?, ? ,?, ?)'); if(!$stmt) { trigger_error('MySQL Error - Unable to prepare query: ' . mysqli_error($mysqli)); } $paramTypes = 'sssss'; // loop over the records and insert data into table foreach ($records as $record) { // bind values to prepared querie $bind_params = array(); $bind_params[] = &$paramTypes; foreach ($record as $key => $value) { $bind_params[] = &$record[$key]; } call_user_func_array(array($stmt, 'bind_param'), $bind_params); // execute the prepared query if(!$stmt->execute()) { trigger_error('MySQL Error- Unable to execute prepared query: ' . mysqli_error($mysqli)); } } As I do not know your table structure you will need to the modify the query. See the code comments between /* and */
  8. Rather than individual variables. It would be better to use arrays. Without seeing example data from your text file this is untested code $lines = file('testfile.txt', FILE_IGNORE_NEW_LINES); // split lines into chunks of 5 $LinesOf5 = array_chunk($lines, 5); $records = array(); // loop over the chunks of lines foreach($LinesOf5 as $lines) { // implode the 5 lines into 1 line $data = implode('', $lines); // explode the data delimeted by # $record = explode('#', $data); // add record to records array $records[] = $record; } // should output 40 records? echo '<pre>'. print_r($records, true) . '</pre>';
  9. To covert the SimpleXML Object into an array you should be able to typecase. Example $xml = new SimpleXMLElement($curl_response); $array = (array) $xml; print_r($array); Why does it need to be an array/variables? Are you not familiar with objects Lassie?
  10. Paste that function into your code or save it to another php file and include it, preferably before this line if(!empty($page)) Then replace these liines db_pagetext = str_ireplace('[i]', '<i>', $db_pagetext); $db_pagetext = str_ireplace('[/i]', '</i>', $db_pagetext); $db_pagetext = str_ireplace('[b]', '<b>', $db_pagetext); $db_pagetext = str_ireplace('[/b]', '</b>', $db_pagetext); $db_pagetext = str_ireplace('[u]', '<u>', $db_pagetext); $db_pagetext = str_ireplace('[/u]', '</u>', $db_pagetext); With the call to the showBBcodes function $db_pagetext = showBBcodes($db_pagetext);
  11. What are you doing here? onsubmit="makeTrans(\'withdraw\');return false;" Are trying to call your withdraw function here when the form submits? If so that will never work. You cannot call PHP functions from javascript.
  12. Then you will need to pass it as an argument when you call the function. See the following for more info http://php.net/manual/en/functions.arguments.php
  13. Not sure but try moving <div class="col-md-7"> <a href="<?php echo $ova->getK2link($value->id,$value->alias,$value->catid,$value->categoryalias); ?>"> <img alt="" src="<?php echo $ova->getImageK2($value->id,'XL'); ?>" /> </a> </div><!--/.col-md-7--> So it is before <div class="col-md-5">
  14. Adding on to cyberRobot's reply you will need run the query before the use of return $res; otherwise the query will never execute. This is because the return statement will terminate the function where it is called, anything after it will never be reachable. For more information please read http://php.net/manual/en/functions.returning-values.php http://php.net/return
  15. Then use header() before any output. Output is considered to be anything that is being echo/print'd or anything that is outside of the <?php ?> tags. The error tells where output was detected Warning: Cannot modify header information - headers already sent by (output started at /home/sbsbitum/public_html/process2.php:5) in /home/sbsbitum/public_html/process2.php on line 60 In red it tells you the location of the file and line number on which the output started. In blue it tells you the location and line number where you attempted to use header(). So what is the first 5 lines of process2.php?
  16. What are you asking? You want to make the user logged in as Jaj to have the role as admin? You could change your login array to something like this $logins = array('raj' => array('raj123@123', 'admin' => true), 'ram' => array('ram@123'), 'dev' => array('dev@123'), ...etc ); Then for logging user in if (isset($logins[$Username]) && $logins[$Username][0] == $Password) { /* Success: Set session variables and redirect to Protected page */ $_SESSION['UserData']['Username']=$logins[$Username]; // This is set to true if the admin key exists and is set to true for user logging in $_SESSION['UserData']['Admin'] = (isset($logins[$Username]['admin']) && $logins[$Username]['admin'] == true); header("location:signin.php"); exit; } else { /*Unsuccessful attempt: Set error message */ $msg="<span style='color:red'>Invalid Login Details</span>"; }
  17. We would need to see the code where it adds the report to the PDF file.
  18. Yes you can call a function within a function. Without seeing your code cant give you a specific answer.
  19. So you dont want the word Wordpress in the phrase From a Wordpress user? If so then delete the word wordpress from that line of code. No need for preg_replace here. if ( $current_user->user_login != '' ) $user_info_string .= __( 'From a user', 'si-contact-form' ) . ': ' . $current_user->user_login . self::$php_eol;
  20. Well if you actually took the time to look a HTML Form tutorial such as this one. It will explain all there is to do with HTML forms and you would of known what to do then. You will never find an exact code example that will solve your problem.
  21. I assume HTTP_X_MXIT_USERID_R contains the users username? If so then try doing a simple str_replace $raw = file_get_contents($source) or die("Cannot read file"); $raw = str_replace("$mxituid\n", "", $raw); file_put_contents($source, $raw); I see no need for regex for removing a user from the file.
  22. Looked back through this topic and may have overlooked something By main directory I take that as xampp's main directory which is C:/xampp/htdocs? So the contents of the htdocs folder reads as C:\xampp\htdocs | |- .htaccess |- record.php +- template | + link.php
  23. This usually means PHP encountered an unrecoverable error. First step is to checked the error logs for your server. Or enable error reporting in the php.ini error_reporting = E_ALL display_errors = On Make sure you restart your http server after making any changes to the php.ini Post the errors you get here If it worked on Windows then it should work on your Ubuntu server. I have a feeling something is not configured correctly on Ubuntu. Once we know what the errors are we can start to assist you better.
  24. Yes that is exactly what the link should look like. I do not understand why it is not working (although test.php should be record.php in the htaccess I forgot to change it back when I pasted the code) Do you require the page name in the url? With my rewriterule it does not need it in the url. The rewriterule should match any url that looks like this /id/<id-here>/name/<category-name-here>. If it finds a match it will get the id and category from the url (this is what this ^id/([0-9]+)/name/([a-zA-Z-]+)/?$ means) and pass these onto record.php as querystring parameters (this is what this record.php?id=$1&name=$2 means). If you really want the page name in the url then this should work too RewriteRule ^record\.php/id/([0-9]+)/name/([a-zA-Z-]+)/?$ record.php?id=$1&name=$2 [L,QSA] If this still does not work. Then I have no idea what else to suggest. Either you have more code in the htaccess which could be interfering or something is amiss with your XAMPP setup.
  25. Use implode to convert the array of ids into a comma delimited list $ids = array(1, 2 , 4); $sql = 'UPDATE table SET annual_leave=1 WHERE id IN ('.implode(',', $ids).')';
×
×
  • 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.