Jump to content

cjackson111

Members
  • Posts

    19
  • Joined

  • Last visited

Everything posted by cjackson111

  1. It should return the average value from the database fields
  2. Hello. I am pulling data, joining two MySQL tables (using php). When I use the following part in my select statement all rows are returned (which I want) even if it does not have a value for 'r_star' SELECT..... challnge.r_star ..... FROM.... But when I use the following, only rows are returned that have values for 'r_star' SELECT..... AVG(challnge.r_star) ..... FROM.... I want to find the average for the field r_star. Any ideas what I may be doing worng? Thanks!
  3. That's what I thought, but when I started specifying it as UTF-8, that is when I started getting the error.
  4. That's what I want to do, fix it from the root, but I am not sure what to do to fix it. Any ideas?
  5. Hello all. I have a php script that creates an xml file pulled from a mysql database. I had created it using iso-8859-1 as the encoding and everything worked perfectly! However, the client wants it encoded at UTF-8. $_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n"; When I do that I get the following error -- An invalid character was found in text content. Error processing resource 'http://www..... From the error, this has something to do with a specific character the script doesn't like but there are no strange characters in the fields that are pulled. Any ideas what may be the problem? I would greatly appreciate any help!
  6. Cool, thanks alot. I'll try it in the morning...too sleepy now
  7. Hello. I am pulling data from a mysql table and want to replace some strings that may appear in the data. Is it possible to use str_replace to replace more than one value at a time? For instance, replace '+' with 'plus' AND '-' with 'minus'. This doesn't work but something like this -- str_replace($search1, $replace1, $subject1, $search2, $replace2, $subject2); Thanks for all help!
  8. I am now trying to ftp the saved file to a remote server but can't seem to get it to work. The following is the code I have for that -- //FTP file to remote server $ftpStream = ftp_connect("ftp.domain.com"); $loginResult = ftp_login($ftpStream, "username@domain.com", "password"); if ($loginResult) { ftp_put($ftpStream, "target.txt", "target.txt", FTP_ASCII); } ftp_quit($ftpStream);
  9. Got it. Thanks so much for your help!
  10. Thanks. I now see that the file is saved on the server, however it does not have the .csv extension to it. Any ideas what I may be doing wrong? I have added the following code -- file_put_contents($filename, $csv_output);
  11. Hello all. I have a script that exports data from mysql to a csv file. Everything works great. However, I do not know how to save the csv file to the server. Does anyone have any ideas how I would do that? The script is below. Thanks for all help! <?php $host = 'localhost'; $user = ''; $pass = ''; $db = ''; $table = ''; $file = 'export'; function escape_csv_value($value) { $value = str_replace('"', '""', $value); // First off escape all " and make them "" if(preg_match('/,/', $value) or preg_match("/n/", $value) or preg_match('/"/', $value)) { // Check if I have any commas or new lines return '"'.$value.'"'; // If I have new lines or commas escape them } else { return $value; // If no new lines or commas just return the value } } $link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error()); mysql_select_db($db) or die("Can not connect."); $result = mysql_query("SHOW COLUMNS FROM ".$table.""); $i = 0; if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $csv_output .= $row['Field'].", "; $i++; } } $csv_output .= "\n"; $values = mysql_query("SELECT * FROM ".$table.""); while ($rowr = mysql_fetch_row($values)) { for ($j=0;$j<$i;$j++) { $csv_output .= escape_csv_value($rowr[$j]).','; //$csv_output .= $rowr[$j].", "; } $csv_output .= "\n"; } $filename = $file."_".date("Y-m-d_H-i",time()); //header( "Content-Type: application/save-as" ); header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("Y-m-d") . ".csv"); header( "Content-disposition: attachment; filename=".$filename.".csv"); //header( "Content-disposition: filename=".$filename.".csv"); print $csv_output; exit; ?>
  12. Ok, I have a little snag. Everything works great except for the last bit (order by date ASC). It still shows whatever record is first in the database. Any ideas what I may be doing wrong? $sql = "select memberid, event, category, date, enddate, locality, location, address, city, state, zip, contact, phone, notes, doc1, doc2, doc3, doc4, doc5 from event where date >= '$datenow' GROUP BY memberid ORDER BY date ASC"; Thanks!
  13. Thanks, that worked! I was thinking I needed to use DISTINCT. I specified to display the first record of each group by adding an order by clause. Thanks for your help!!!
  14. No, I only want to show one record that has the same memberid. For instance, I have 5 similar records that all have the same memberid. I only want to show one of them
  15. Hello. I am trying to display only one instance of records that have the same memberid in my db. I am using the following statement but it continues to show all of the records that have the same memberid. Any ideas what I may be doing wrong? $sql = "select DISTINCT memberid, event, category, date, enddate, locality, location, address, city, state, zip, contact, phone, notes, doc1, doc2, doc3, doc4, doc5 from event where date >= '$datenow' ORDER by date ASC"; Thanks for any help!
  16. Ahhhhh! Works like a charm now. You are awesome! Thank you very much!!!
  17. How would I set it to ignore any blank entries? I am fairly new to this. Thanks
  18. Sure, here is my php code which reads and displays the xml data. <?php //if ( isset( $_POST['zip'] ) ) //echo $zip; if( ! $xml = @simplexml_load_file("http://api.jambase.com/search?zip=$zip&radius=$radius&n=75&apikey=[my api key]") ) { echo 'unable to load XML file'; } else { //echo 'XML file loaded successfully'; echo '<table width="590" cellpadding="6" cellspacing="0">'; foreach( $xml as $event ) //foreach( $xml as $user ) { echo '<tr valign="top" bgcolor="#000000">'; echo '<td width="300" background="image/bg_results2.gif"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>'; echo ''.$event->artists->artist->artist_name.''; //artist_name echo '</strong><br> '.$event->event_date.'<br> Live at '.$event->venue->venue_name.'<br> '.$event->venue->venue_city.', '.$event->venue->venue_state.' '.$event->venue->venue_zip.''; echo '</font></td>'; echo '<td width="290" align="right" background="image/bg_results2.gif"> <a href="'.$event->event_url.'" target="_blank"><img src="image/detail_button.gif" alt="Event Details" vspace="5" width="71" height="25" border="0"></a>'; //event link //echo ' '; if (!$event->ticket_url){ } else{ echo ' <a href="'.$event->ticket_url.'" target="_blank"><img src="image/ticket_button.gif" alt="Get Tickets" vspace="5" width="71" height="25" border="0"></a>'; //ticket link } echo '</td>'; echo '</tr>'; } echo '</table>'; } ?>
  19. Hello all. I am using an API from jambase.com to display events on a php page. Everything works great, the xml file is read and the data is displayed on the page as it should. My only problem is that when the data is displayed there is always a blank area where the first record of data should go. Any ideas how to get rid of this? http://www.wddclients.com/mag33/events_search.php (artist search field not enabled yet) Hopefully this is something pretty minor but if anyone wants to see specific code I can supply that. Thanks so much for all help!
×
×
  • 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.