Jump to content

lordshoa

Members
  • Posts

    84
  • Joined

  • Last visited

    Never

Everything posted by lordshoa

  1. I think amend to file not write to file txt_fns.php function writeTable $fp = @fopen($tablename, "w"); fwrite($fp, $output, strlen($output)); fclose($fp); } So should be $fp = @fopen($tablename, "a+"); fwrite($fp, $output, strlen($output)); fclose($fp); }
  2. I use a function csvToArr So result has to be an array which is the title of the cvs colum The problem is it works correctly with php5.2 and php5.4 but in 5.3 it was giving out the error (Fatal error: Cannot use string offset as an array) I am wondering if it will suddenly break, if the server gets updated to a php version that stops it working how it is now. How could I make it different but with the same code as this runs as a cron. function csvToArr($filepath) { $headings = array(); // Array of headings $filedata = array(); // Data Array // Get file handle $handle = fopen($filepath, "r")or die('cannot open end.txt to get array'); // Get field headings $fileline = fgetcsv($handle, filesize($filepath), ";"); foreach( $fileline as $field ) { $headings[] = $field; } // Get data $line = 0; if ($line == 0 ){ while (($fileline = fgetcsv($handle, filesize($filepath), "\t")) !== FALSE) { foreach( $headings as $k => $v ) { // Store data against field headings $filedata[$line][$v] = $fileline[$k]; } $line++; } fclose($handle); } return $filedata; } $result = csvToArr($filename);
  3. Trying to understand this error a little more. Fatal error: Cannot use string offset as an array I have a csv fie that is put in to an array I then count lines the array and my var comes out as $result = array titles [$i] = the count ['proid'] = string id $result[$i]['proid'] Am I using the output wrong as I am using it as a $var should I be putting it as $key as $value instead ? So I use it as if ($result[$i]['proid'] == 2222){ do something} Is this wrong ? I was updating it on my dev machine and was getting the error in php 5.3 but not in 5.2 or 5.4 bug or change ?
  4. somethig like that mysql_query($sql); if(mysql_affected_rows($sql)){ print 'inserted correctly'; }
  5. echo' <option value="'. $folderPath. '"">' . $folderName . '</option>'; echo" <option value='". $folderPath. "'>'" . $folderName . "'</option>";
  6. look at the function mysql_affected_rows()
  7. they just hold a $var that is the start for the search and the end of the search So If i was searching in a txt file it would look for the the word start say $begining - 'start'; $finish = 'end'; search for the word start hold everything in between untill you find the word end from the file $stuff add eveything inbetween to the var $cont
  8. I am sure I have tried that and loads of other variations of it but will give it another go. Will have to wwrite them down as I go this time as not to keep trying the same thing. Just gave it ago and the output is blank.
  9. The category seem to be mssing from the form drop down so you cannot select them maybe look at the code and see why they are missing Undefined index: category City option is missing from the send form as I can see it [district] => 3 [tel] => The array should be [district] => 3 [city] => [tel] =>
  10. Missing form infront of your post Vars if(empty($_POST['social'])) { $errorMessage .= "<li>You forgot to enter a Social Media Platform!</li>"; } if(empty($_POST['url'])) { $errorMessage .= "<li>You forgot to enter a URL!</li>"; } if(empty($_POST['formsocial'])) { $errorMessage .= "<li>You forgot to enter a Social Media Platform!</li>"; } if(empty($_POST['formurl'])) { $errorMessage .= "<li>You forgot to enter a URL!</li>"; }
  11. Need to change from ergi to preg_match if some one is good with regex thanks for any help eregi("$begin(.*)$finish", $stuff, $cont);
  12. Are these variables empty on the script ? they should be for one and removing code injection so only number letters used $username = ''; or $username = $_POST['myusername']; [code] [code] $host= $username = $password= $db_name= $tbl_name= These vars are empty and they do not have a code end ; Is there a form that you post from maybe that is not correct?
  13. What is the code around the line 314 of the institute_registration_form.php '/home/www/lankainstitute.com/centersignup/institute_registration_form.php' on line 314: Undefined index: category '/home/www/lankainstitute.com/centersignup/institute_registration_form.php' on line 314: Invalid argument supplied for foreach()
  14. <?php mysql_connect("localhost","root",""); mysql_select_db("sample"); echo "Product Volume: 3.75<br>"; echo "Amount: 1.5<br>"; $total=3.75*1.5; $total = substr_replace($total ,"",-1); echo "Total: ".$total; $total_insert=mysql_query("insert into test (price) values ('".$total."')"); ?>
  15. can you not trim the last char off ?
  16. thanks Do not know why I had the wrong query as my working example for myself. UPDATE `details` SET fulldescr = replace(`fulldescr`, 'This overview section', 'The product description section') WHERE `id`='14514' LIMIT 1
  17. I am trying to replace the text with diffarent text, but there is more text in the row field that I want to keep as each row is diffarent. I used code below to change text in a field before and worked perfectly well with SELECT SELECT Replace(image_path , '..', '.') FROM `images`
  18. my.cnf bind address is correct ??? Maybe try 127.0.0.1 instead of localhost Are you using a server or home server ?
  19. Having trouble replacing text in a field, mysql does it stuff but does not change the text but says successful ? SELECT Replace( `fulldescr`,'This overview section','The description section') FROM `details` WHERE `id` = '14514' LIMIT 1 Any help would be great Thanks
  20. just used ultimate compare to save you answering me. Result = good no php or mysql needed.
  21. works for me if it looking at the false is correct but the code works then the error message is wrong so swapping them round would give the opposite effect yes ? As the CODE WORKS
  22. I am trying to help him write his own code not write it for him like you he wont learn from other people writing it for him. And how does it not relate ? only need to change the var to $tID
  23. all he is trying to do is get a good message when it has deleted not if it has deleted he knows its deleting it. So swapping the error message around would make a false positive a positive false. He did not say he wanted to know if it has deleted anything from the mysql just to get a good message when the right id is used. As he knows the rows are being deleted. if(mysql_query($result,$con)){ echo "$i encountered an error.<br/>"; } else { echo "$i successfully inserted.<br/>"; } not correct @mysql_close($conn); correct mysql_close($con);
  24. So you get error on sucess and on error the same message ? Maybe try and explain better saying Yes I Done This does not explain to me what you did and what the result was.
×
×
  • 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.