Jump to content

ThunderAI

Members
  • Posts

    102
  • Joined

  • Last visited

Everything posted by ThunderAI

  1. My initial thoughts are to have three tables. One table will have the following structure: ID | code | name | club | points | price then another table with this strucure: ID | Month_ID | W_points | Parent_ID ID | Month_name Parent_ID is an index forgien key to the first Tables ID field. the last table ID is an Index forgien key to the second to last table. When information is added to the second to last table, a function is called that adds the points to the first table. In order to get the number of points in a month you add up all rows with the proper month_ID.
  2. It never is brought into a DB, its read into an array and then pared against something already in a DB. The CSV file never is imported. I could add the slahes when I read the data into the array. But how? Here is the code to explode the line of the CSV file into an array $line = trim($fcontents[$i],','); $arr = explode(",",$line);
  3. The information comes from a CSV file. If I manualy add the slashes into the CSV file it works. I suppose I could do a search of the column see if there is a ' in it and add a \ right before it. What would that code even look like?
  4. Just how do I do that? Here is a typical sql statement: $nsql = '(`fieldname` LIKE CONVERT(_utf8 \'%'.$arr[0].'%\' USING latin1) COLLATE latin1_swedish_ci '; a name like O'Reily would go in the array $arr[0]. If I try to put two ''s in name then the program crashes. What am I missing?
  5. The SQL works without error when entereted into PHPMyAdmin. If the user uploads a file with a different name i need to save the name of the file, so I dont see how removing the name will benefit me. Tried it again this morning and I get the same error.
  6. I admit this isn't really just a PHP problem, but it does have PHP elements to it. Here is my problem. I have an SQL statement that works and will submit data to the MYSQL table, BUT MySQL gives an error message. Any ideas? Here is the error statement: 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 'files/1/KATY.csv', user_f_rows = '42' WHERE user_f_id = '1' ] ')' at line 1 the sql statement print out is: SQL is [[[ UPDATE tbl_users_files SET user_f_name = 'files/1/KATY.csv', user_f_rows = '42' WHERE user_f_id = '1' ]]] This error happens reguardless if i am overwiting an exisiting file or not. It does add the new record to the DB with all of the right information. here is the code: <? else { $objrs_support = mysqli_query($objconn_support, $sql); if ($objrs_support) { $number_of_rows = mysqli_num_rows($objrs_support); if ($number_of_rows == 0) { // There are no records, so this is a new entry $sql2 = "INSERT INTO tbl_users_files (user_f_name,user_f_rows, user_f_parent_id) VALUES ( '".$target_path."', '".$rowcounter."', '".$tmp_userid."' )"; } while ($objfields = mysqli_fetch_array($objrs_support, MYSQLI_ASSOC)) { $tmp_user_f_id = $objfields['user_f_id']; $sql2 = "UPDATE tbl_users_files SET user_f_name = '".$target_path."', user_f_rows = '".$rowcounter."' WHERE user_f_id = '".$tmp_user_f_id."' "; echo "SQL is [[[ ".$sql2." ]]]"; } } } //echo $sql2; $mysqli = mysqli_connect("-", "-", "-", "-"); if (mysqli_connect_errno()) { // there was an error trying to connect to the mysql database printf("connect failed: %s\n", mysqli_connect_error()); exit(); } else { $objrs = mysqli_query($mysqli, $sql2) or die(mysqli_error($mysqli)); //printf("Last inserted record has id %d\n", LAST_INSERT_ID()); //echo mysql_insert_id($mysqli); } $function = "Uploaded a new User CSV file with SQL Statement [ ".$sql2." ] "; put_systemactivity($_SESSION["user_id"],$function); ?> Please pardone the code, im not a great programmer, just a programmer.
  7. That looks good, what about the following situation tbl_users > user_id > user_name tbl_activity > activity_id > activity_user_id SELECT * FROM tbl_activity INNER JOIN tbl_users ON tbl_users.user_id = tbl_activity.activity_user_id Can your table do the relation of those two tables automatically or how do i pass what fields I want displayed?
  8. Just displaying table data in row format. By many different tables i mean it can support tables that have primary and child key fields, like in InnoDB tables. And the code can be reused for a different table by chaning only a few lines of code.
  9. Does anyone have a good module or 3rd party code that they use to display rows of data across many different tables? I am looking into redesigning the code i use for the datagrid and i was curious what was out there.
  10. I dont do anything fansy with the header() command, but i have never had a problem with sessions either. The very first thing in any of my code is this: <?php // Include Files nessary to complete any tasks assigned. include("includes/generalsettings.php"); include("includes/functions.php"); ?> generalsettings contains information about the database to use and each of the session fields. The applicable part looks like: <?php Session_Start(); Session_Register("user_id"); Session_Register("user_name"); Session_Register("user_password"); Session_Register("user_email"); ?> In my experience the session will pull the last value set to it from any other page, so each of these variables are only set in the log in function and i can use them in any other page so long as the session is initiated on that page.
  11. Here is the code for a progress bar i use. <?php // This Div layer will show a precent completed of the current search query. It relates directly // to the procedures that follow the While loop. ?> <div id="myDiv" style="display:none; position:absolute; z-index:9; left:0; top:0; width:302;"> <table width="100%" Class="windowMain" CELLSPACING=1 CELLPADDING=2> <tr> <td class="newTopicTitle">Search Query Progress</td> </tr> <tr> <td class="newTopicBoxes"> <div id="myDiv_bar" style="display:none; width:0; background-color: #7198BF;background-image:url('images/animated_timer_bar.gif'); background-repeat:no-repeat;background-position: left center;"> <table> <tr> <td class="newTopicTitle" id="percent" align="center" valign="middle"> </td> </tr> </table> </div> </td> </tr> <tr> <td colspan="2" class="newTopicEnder"> </td> </tr> </table> //echo "Number of Rows Found Across all Cycles ".$totalcellsfound." <br>"; //echo "Number of Empty Returns Across all Cycles ".$totalcellsblanks." <br>"; //echo "There are ".$totalsize." rows in each cycle <br>"; //echo "Increase tmp_a by the totalsize <br>"; $tmp_a = ( $tmp_a + $totalsize ); //echo ">>> a > The Value is ".$tmp_a." <br>"; //echo "The DIV layer is 300 pixels wide, what percent of the pixel is completed? <br>"; $tmp_b = ( (300 / $scobby) / $totalexpectedcycles ); //echo ">>> b >The Vlaue is ".$tmp_b." <br>"; //echo "Take the percentage times the amount of records completed, and round the result <br>"; $tmp_c = round(( $tmp_b * $tmp_a ),0); //echo ">>> c > The Value is ".$tmp_c." <br>"; //echo "What percent of the progress bar is completed? <br>"; $tmp_d = ( round( ( $tmp_c / 300 ), 4 ) * 100 ); //echo ">>> d > The value is ".$tmp_d." <br>"; //echo "--------------------------------------------------------------------- <br>"; ?> <script> document.getElementById("myDiv").style.display = "block"; document.getElementById("myDiv_bar").style.display = "block"; document.getElementById("myDiv_bar").style.width = "<?=$tmp_c;?>"; document.getElementById("percent").innerHTML = "<font color='#FFFFFF'><?=$tmp_d;?>%</font>"; //alert('You have unread messages \n Please check them by clicking the Notice Button'); </script> <script> document.getElementById("myDiv").style.display = "none"; document.getElementById("myDiv_bar").style.display = "none"; //alert('You have unread messages \n Please check them by clicking the Notice Button'); </script>
  12. I personaly dont understand why you would not use ajax for this type of setup. That or the simple $_GET['id'] to another target window. Or better yet, a hidden div layer that when unhidden will display the contents of that row.
  13. First suggestions works 100% correctly. Second one looks cleaner, but adds an extra line space in between every row. Is there a way to remove that extra line space?
  14. How do you go about deleting the first x number of lines of a CSV. I want the first three or one line deleted. I could open the file and read the lines, but how do I physicaly delete them so they are not read by the LOAD DATA function.
  15. I think I got it to work, well it works, but i am sure it is not perfect. <?php // starting excel $excel = new COM("excel.application") or die("Unable to instanciate excel"); print "Loaded excel, version {$excel->Version}\n"; //bring it to front //$excel->Visible = 1;//NOT //dont want alerts ... run silent $excel->DisplayAlerts = 0; //open document $excel->Workbooks->Open("file"); //XlFileFormat.xlcsv file format is 6 //saveas command (file,format ......) $sheet = $excel->WorkSheets(3); $sheet->activate; $excel->Workbooks[1]->SaveAs("fileb",6); //closing excel $excel->Quit(); //free the object unset($excel); //$excel->Release(); $excel = null; ?> The thing I am not sure about is the release of the $excel object.
  16. As I sadi, COM is a little out of the scope for a php frum. Hell, I don't even use windows let allone com or excel. You'll want to google for information regarding the excel.application object. ok, will do.. and report back
  17. Thanks for the direction... I found this on the PHP manual site: Simple convert xls to csv <?php // starting excel $excel = new COM("excel.application") or die("Unable to instanciate excel"); print "Loaded excel, version {$excel->Version}\n"; //bring it to front #$excel->Visible = 1;//NOT //dont want alerts ... run silent $excel->DisplayAlerts = 0; //open document $excel->Workbooks->Open("C:\\mydir\\myfile.xls"); //XlFileFormat.xlcsv file format is 6 //saveas command (file,format ......) $excel->Workbooks[1]->SaveAs("c:\\mydir\\myfile.csv",6); //closing excel $excel->Quit(); //free the object $excel->Release(); $excel = null; ?> it looks deseptivly simple, but there is no mention as to the actual workbook page. How do I gain access to a specific page?
  18. Yes, i know a csv would be better, yes i know load data is better. Unforuntitly i need to gain access to one page of an excel sheet in a workpage called 'add'. There are many posts on this site which talk about excel, ut i dont understand where to start. I know how to import a csv using file(), but how do you import one worksheet from an xls file into MySQL?
  19. Is just checking the value in a session user id ok. I was able to do that and everything works how i want it to; however, would there be a better way?
  20. in the php help section there is a topic about preventing direct access to a php file unless it is in an iframe. in order to tell this i used this function. <script> var youraterrorist if (top.location == self.location) { alert('your bad'); document.write('your bad'); youraterrorist = 1; } else { alert('your good'); youraterrorist = 0; } </script> is it possible for the javascript to actally terminate the rest of the file if this test fails?
  21. I tried this code on a page withinan iframe, and PHP kust blocks access to it weather or not it is in an iframe. In fact, I am not sure I even gain access to the file with this 404 function.
  22. Here is what I did: The javascript: <script> function closenotice() { document.getElementById("myDiv").style.display = "none"; } </script> The Div: <div id="myDiv" style="display:none; position:absolute; z-index:9; left:300; top:300; width:400;"> <input type="submit" value="Close this Window" name="submit" class="button" onclick="javascript:closenotice();"> </div> The PHP/More javascript: <?php if ($tmp_number > 0) { ?> <script> document.getElementById("myDiv").style.display = "block"; //alert('You have unread messages \n Please check them by clicking the Notice Button'); </script>
  23. I have function that counts the number of notices a user has and if it is over 0 i want either an alert or a custom div layer to apear. How can I set up the javascript to activate if the function passes a number over 0 to it?
  24. I dont know if I have an awer to your question, but something i noticed. I would stay away from tables, stored procedures, and the like with spaces in them. I always name my tables tbl_x, and my other stuff with appropriate header. The oher thing i noticed is that the syntax you are using for your sql is not breaking the text to allow for the form variable. I understand how your doing it works, but i dont find it easy to read. That and your last two lines look to be causing the problem to me.. Why do you need both lines there. What happends if you leave out "$result_TradeAndTechnical_add = mysql_query($query_TradeAndTechnical_add);"
  25. How do you see the code behind an ASP document. is there a way to download the actual file and not the HTML rendered?
×
×
  • 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.