thomasw_lrd Posted October 15, 2012 Share Posted October 15, 2012 I've just run into a really weird error. I'm hoping someone can help. When I run the code with the $rs = myexecute($sql); line commented out, it prints INSERT INTO tbl_full_text set ft_path = '../intranet/Documents/CPOA 2011/Account Receivable - (Don\'t Touch)/AR 1001-1100 Series/PMI -1 - AR-1001/RE PMI Technologies - Cardio POs (43).msg'; INSERT INTO tbl_full_text set ft_path = '../intranet/Documents/CPOA 2011/Account Receivable - (Don\'t Touch)/AR 1001-1100 Series/PMI -1 - AR-1001/RE PMI Technologies - Cardio POs (44).msg'; INSERT INTO tbl_full_text set ft_path = '../intranet/Documents/CPOA 2011/Account Receivable - (Don\'t Touch)/AR 1001-1100 Series/PMI -1 - AR-1001/RE PMI Technologies - Cardio POs (45).msg'; INSERT INTO tbl_full_text set ft_path = '../intranet/Documents/CPOA 2011/Account Receivable - (Don\'t Touch)/AR 1001-1100 Series/PMI -1 - AR-1001/RE PMI Technologies - Cardio POs.msg'; INSERT INTO tbl_full_text set ft_path = '../intranet/Documents/CPOA 2011/Account Receivable - (Don\'t Touch)/AR 1001-1100 Series/PMI -1 - AR-1001/RE PMI Technologies Account Receivable 4170.msg'; INSERT INTO tbl_full_text set ft_path = '../intranet/Documents/CPOA 2011/Account Receivable - (Don\'t Touch)/AR 1001-1100 Series/PMI -1 - AR-1001/RE PMI.msg'; Which is offsets 0-5. When I uncomment that line I get this. Can anyone help? myexecute is a custom function for inserting data into our database. It handles all the error processing, and credentials. INSERT INTO tbl_full_text set ft_path = '../intranet/Documents/CPOA 2011/Account Receivable - (Don\'t Touch)/AR 1001-1100 Series/PMI -1 - AR-1001/RE PMI Technologies - Cardio POs (43).msg'; Notice: Undefined offset: 1 in /var/www/portal.certifiedpreownedincome.com/www/app/test.php on line 16 Notice: Undefined offset: 1 in /var/www/portal.certifiedpreownedincome.com/www/app/test.php on line 17 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 SELECT id, parent, name from folders where id = ; <?php include (dirname(__FILE__).'/../includes/menuhead.inc'); include ('apptable_functions.inc'); require('includes/html2text.php'); //PHP Error Reporting ini_set('display_errors',1); error_reporting(-1); $sql = "SELECT filename, parent from files where filename like '%.msg';"; $rs = myload($sql); $count = count($rs); echo $count; echo "<br>"; for($i = 0; $i < 6; $i++){ $path = $rs[$i]['filename']; $parent = "SELECT id, parent, name from folders where id = ".$rs[$i]['parent'].";"; $parent_rs = myload($parent); $folder = $rs[$i]['parent']; do { $parent = "SELECT id, parent, name from folders where id = ".$folder.";"; $parent_rs = myload($parent); $folder = $parent_rs[0]['parent']; $path = $parent_rs[0]['name'] ."/". $path; } while ($folder >= 1); $path = "../intranet/". $path; $fplog = fopen($path,'r'); $string = fread($fplog, filesize($path)); $string = preg_replace("/[^A-Za-z0-9 ]/", '', $string); $string = addslashes($string); $path = addslashes($path); $sql = "INSERT INTO tbl_full_text set ft_path = '$path';";//, ft_data = '$string';"; echo $sql; echo "<br>"; //$rs = myexecute($sql); } Link to comment https://forums.phpfreaks.com/topic/269502-having-a-problem-inserting-data/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 15, 2012 Share Posted October 15, 2012 Your code is using the $rs variable to hold the result form the first select query. When you overwrite the $rs variable, it no longer contains the result set that your loop is referencing. Link to comment https://forums.phpfreaks.com/topic/269502-having-a-problem-inserting-data/#findComment-1385386 Share on other sites More sharing options...
thomasw_lrd Posted October 15, 2012 Author Share Posted October 15, 2012 I am an idiot. Thank you so much. Link to comment https://forums.phpfreaks.com/topic/269502-having-a-problem-inserting-data/#findComment-1385388 Share on other sites More sharing options...
Pikachu2000 Posted October 16, 2012 Share Posted October 16, 2012 I am an idiot. No, you aren't. True idiots never admit it, because they're too idiotic to realize they're idiots. Link to comment https://forums.phpfreaks.com/topic/269502-having-a-problem-inserting-data/#findComment-1385422 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.