Jump to content

Grant Holmes

Members
  • Posts

    221
  • Joined

  • Last visited

    Never

Everything posted by Grant Holmes

  1. It is so frustrating to have something work one place, copy it over and have it break. Where is the AAAAAAARRRRRRRRRRRRRRGGGGGGGGGGGG emoticon??? I figured there was something wrong
  2. kenrbnsn, I used your first option, for the moment. That removed the error. THANKS!!! However, upon changing a field and hitting "Update", the form "acts" correctly, taking me back to my song list, but the edits to the table do not happen.
  3. PFMaBiSmAd Where would I find the PHP.ini?? I have access to Plesk and PHPmyAdmin on this host.
  4. Sorry, I had intended to post the code, but "preview" (the post) isn't working today and forgot all about it. <?php include_once("security/MYsecurity.php"); ?> <?php $DOCROOT = $_SERVER['DOCUMENT_ROOT'] ; ?> <? $id = $_REQUEST["id"]; include("dbinfo.inc.php"); mysql_connect($dbhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); if (!empty($_REQUEST["submit"])) { extract($_REQUEST); if ($_REQUEST["submit"] == "Delete") { $query = "DELETE FROM SongList WHERE id=".$ud_id; $result=mysql_query($query); header("Location: song_list.php?del=1"); } else { $query='UPDATE SongList SET active = "'.$ud_active.'", SongTitle = "'.$ud_SongTitle.'", ArtistPrimary = "'.$ud_ArtistPrimary.'", ArtistSecondary = "'.$ud_WriterPrimary.'", WriterSecondary = "'.$ud_WriterSecondary.'", Contact_Info_ZipCode = "'.$ud_RelatedURL.'", RelatedURL = "'.$ud_Comments.'", PartOf = "'.$ud_PartOf.'", SongStatus = "'.$ud_SongStatus.'", SongPace = "'.$ud_SongPace.'" Minutes = "'.$ud_Minutes.'", YearRecorded = "'.$ud_YearRecorded.'", YearWritten = "'.$ud_YearWritten.'", RecordLabel = "'.$ud_RecordLabel.'", Lyrics = "'.$ud_Lyrics.'", active = "'.$ud_active.'" WHERE id = "'.$ud_id.'"'; $result=mysql_query($query); header("Location: song_list.php?id=".$ud_id); } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <TITLE>Edit Request</TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <META NAME="GOOGLEBOT" CONTENT="NOARCHIVE"> <META NAME="ROBOTS" CONTENT="NONE"> <LINK REL="stylesheet" TYPE="text/css" HREF="CSS/SEC.css"> </HEAD> <?php $query='SELECT * FROM SongList where id = "'.$id.'"'; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<H1>Edit Song Details</H1>"; ?> <center><div style='width:100%; background-color:silver; text-align:right'> <?php SECShowAdminLink(); ?> <?php SECShowLogoutLink(); ?> </div></center> <table border="1" cellspacing="2" cellpadding="2" width="800" class="sortable"> <tr> <th width="130">Song info</th> <TH valign="top" width="30">Comments</TH> <TH valign="top" width="30">Lyrics</TH> <TH valign="top" width="30">Details</TH> <th> </th> </tr> <? $i=0; while ($i < $num) { $active=mysql_result($result,$i,"active"); $SongTitle=mysql_result($result,$i,"SongTitle"); $ArtistPrimary=mysql_result($result,$i,"ArtistPrimary"); $ArtistSecondary=mysql_result($result,$i,"ArtistSecondary"); $WriterPrimary=mysql_result($result,$i,"WriterPrimary"); $WriterSecondary=mysql_result($result,$i,"WriterSecondary"); $RelatedURL=mysql_result($result,$i,"RelatedURL"); $Comments=mysql_result($result,$i,"Comments"); $PartOf=mysql_result($result,$i,"PartOf"); $SongStatus=mysql_result($result,$i,"SongStatus"); $SongPace=mysql_result($result,$i,"SongPace"); $Minutes=mysql_result($result,$i,"Minutes"); $YearRecorded=mysql_result($result,$i,"YearRecorded"); $YearWritten=mysql_result($result,$i,"YearWritten"); $RecordLabel=mysql_result($result,$i,"RecordLabel"); $Lyrics=mysql_result($result,$i,"Lyrics"); $id=mysql_result($result,$i,"id"); ?> <form method="post"> <input type="hidden" name="ud_id" value="<? echo $id; ?>"> <tr> <td valign="top"><STRONG>Title: <input type="text" name="ud_SongTitle" value="<? echo $SongTitle; ?>"><BR> Artists: </STRONG> <input type="text" name="ud_ArtistPrimary" value="<? echo $ArtistPrimary; ?>"><input type="text" name="ud_ArtistSecondary" value="<? echo $ArtistSecondary; ?>"> Writers: <input type="text" name="ud_WriterPrimary" value="<? echo $WriterPrimary; ?>"><input type="text" name="ud_WriterSecondary" value="<? echo $WriterSecondary; ?>"><BR> Status: <input type="text" name="ud_SongStatus" value="<? echo $SongStatus; ?>"><BR> <SMALL>1-On Playlist<BR>2-Needs Added<BR>3-No Track</SMALL><BR><BR> Pace: <input type="text" name="ud_SongPace" value="<? echo $SongPace; ?>"><BR> <SMALL>Slow Medium Faster Smokin</SMALL> </td> <TD valign="top" width="30"> <textarea id="Comments" name="ud_Comments" rows="20" cols="40" wrap='physical'> <?php echo $Comments; ?></textarea></TD> <TD valign="top" width="30"> <textarea id="Lyrics" name="ud_Lyrics" rows="20" cols="40" wrap='physical'> <?php echo $Lyrics; ?></textarea></TD> <TD valign="top" width="30"> <SMALL>Length:</SMALL> <input type="text" name="ud_Minutes" value="<? echo $Minutes; ?>"><BR><BR> <SMALL>Recorded in:</SMALL> <input type="text" name="ud_YearRecorded" value="<? echo $YearRecorded; ?>"><BR><BR> <SMALL>Year Written:</SMALL> <input type="text" name="ud_YearWritten" value="<? echo $YearWritten; ?>"><BR><BR> <SMALL>Year Written:</SMALL> <input type="text" name="ud_RecordLabel" value="<? echo $RecordLabel; ?>"><BR><BR> </TD> <TD valign="top"> <?php $checked = $Active ? 'checked' :''; echo "active ? <input type='checkbox'' name='ud_active'' value='1' $checked>"; ?> </TD> <TD rowspan="2" valign="top"> <CENTER><input type="submit" name="submit" value="Update"> <BR><BR><input type=button value="Cancel" onClick="history.go(-1)"><BR><BR> <input type="submit" name="submit" value="Delete" onclick="return confirm('Are you sure you want to delete this record? This cannot be undone!')"></CENTER> </form></TD> </TR> <TR> <TD valign="top" colspan="2"><SMALL>Related URL:</SMALL><BR> <textarea id="RelatedURL" name="ud_RelatedURL" rows="1" cols="50" wrap='physical'> <?php echo $RelatedURL; ?></textarea> </TD> <TD valign="top" colspan="2"> <SMALL>Part Of:</SMALL><BR> <textarea id="PartOf" name="ud_PartOf" rows="1" cols="50" wrap='physical'> <?php echo $PartOf; ?></textarea> </TD> </TR> <? ++$i; } echo "</table><BR>"; ?>
  5. See this post for related information. We fixed that one... Once you pass the page listed above, I have a page where I list songs that are on my "playlist" At the end of the row, there is an "edit" link where you can go to edit the record. I take the user then to "song_edit.php" code below. The problem is like the one listed above. This same type edit file is used OFTEN. I open/save as and make the db edits. So again, am mostly certain that is not the issue. I'm thinking this host is the issue. Nonetheless, I need to fix this. On this file, when I edit a field and hit "UPdate" I get this error: Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/grantholmes.com/httpdocs/datatube/songs_edit.php:4) in /var/www/vhosts/grantholmes.com/httpdocs/datatube/songs_edit.php on line 36
  6. I WISH I got royalties from these folks, but I don't. Sigh. Forms to go Especially if like me, you're a little weak on PHP
  7. The one file I hadn't checked for a space was the "MYsecurity" file. Sure 'nuff, there it was. Funny how at other hosts/servers the same space is there, but not causing an issue. Thanks guys!!
  8. Haku, I believe the session is being set in that include. Here's an example page: <?php include_once("security/Mysecurity.php"); ?> <?php $DOCROOT = $_SERVER['DOCUMENT_ROOT'] ; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <TITLE>private data management- your IP has been recorded.</TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <META NAME="GOOGLEBOT" CONTENT="NOARCHIVE"> <META NAME="ROBOTS" CONTENT="NONE"> <LINK REL="stylesheet" TYPE="text/css" HREF="CSS/SEC.css"> </HEAD> <BODY><H1>Please choose...</H1> <a name="top"></a> <P> <!-- search code and form from http://php.about.com/od/phpwithmysql/ss/php_search_2.htm --> <?php if (!empty($_REQUEST["id"])) { echo "<center><FONT color=\"#ff0000\"><B>Record Updated</B></FONT></center>"; } if (!empty($_REQUEST["del"])) { echo "<center><FONT color=\"#ff0000\"><B>Record Deleted</B></FONT></center>"; } ?> <center><div style='width:100%; background-color:silver; text-align:right'> <?php SECShowAdminLink(); ?> <?php SECShowLogoutLink(); ?> </div></center> <center><div style='width:100%; background-color:#ffe4c4; text-align:center'><BR> <A href="#top"><IMG src="images/uparrow.gif" border="0" hspace="2" vspace="4" /></A><A href="#bottom"><IMG src="images/downarrow.gif" border="0" hspace="4" vspace="4" /></A> Up/Down arrows on pages will take you to the top of bottom of the page.<BR><BR></div></center> <!-- *********************************************************** --> <form name="search" method="post" action="<?=$PHP_SELF?>"> <P>Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="SongTitle">Song Title</option> <Option VALUE="ArtistPrimary">Artist Primary</option> <Option VALUE="ArtistSecondary">Artist Secondary</option> <Option VALUE="WriterPrimary">Writer Primary</option> <Option VALUE="WriterSecondary">Writer Secondary</option> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /></P> </form> <!-- *********************************************************** --> <?php //This is only displayed if they have submitted the form if ($searching =="yes") { echo "<h2>Results</h2><p>"; //If they did not enter a search term we give them an error if ($find == "") { echo "<p>You forgot to enter a search term"; include "include/footer.php"; exit; } // Otherwise we connect to our Database include("dbinfo.inc.php"); //mysql_connect("localhost", "director", "sher!0ck"); mysql_connect($dbhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //Now we search for our search term, in the field the user specified $data = mysql_query("SELECT * FROM SongList WHERE upper($field) LIKE'%$find%'"); //And we remind them what they searched for echo "<b>Searched For:</b> " .$find; echo " <A href=\"#top\"><IMG src=\"images/uparrow.gif\" border=\"0\" hspace=\"2\" vspace=\"4\" /></A><A href=\"#bottom\"><IMG src=\"images/downarrow.gif\" border=\"0\" hspace=\"4\" vspace=\"4\" /></A><br><table border=\"1\" cellspacing=\"2\" cellpadding=\"3\">"; //And we display the results while($result = mysql_fetch_array( $data )) { echo "<TR><TD valign=\"top\">"; echo $result['id']; echo "</TD><TD valign=\"top\">"; echo $result['SongTitle']; echo " "; echo $result['ArtistPrimary']; echo "</TD><TD valign=\"top\">"; echo $result['ArtistSecondary']; echo "</TD><TD valign=\"top\">"; echo $result['WriterPrimary']; echo "</TD><TD valign=\"top\">"; echo $result['WriterSecondary']; echo "</TD><TD valign=\"top\">"; echo "<a href='search_edit.php?id=".$result['id']."''>edit</a></TD>"; echo "<TR>"; } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } echo "</TABLE>"; //And we remind them what they searched for echo "<b>Searched For:</b>" .$find; echo " <A href=\"#top\"><IMG src=\"images/uparrow.gif\" border=\"0\" hspace=\"2\" vspace=\"4\" /></A><A href=\"#bottom\"><IMG src=\"images/downarrow.gif\" border=\"0\" hspace=\"4\" vspace=\"4\" /></A>" ; } ?> <!-- *********************************************************** --> <?php include "include/footer.php"; ?> <a name="bottom"></a> </BODY> </HTML> Schilly: I did have a couple lines where the PHP start did have a space or two before the tag. Two issues: 1- the other pages that work have them too. 2- I removed them and have the same error showing.
  9. I have a 'folder security" piece that I had written several years ago. It tracks log-ins and who/when people have logged in, etc. Then in any file in that folder you want secure, you: <?php include_once("security/MYsecurity.php"); ?> As the first line of that file. This contains various things like info on how to check for allowed users, etc. The biggest point here is that I've used this "code" (which used 2-3 pages of stuff to do what it does) on at least 5 or 10 websites in the last 3 years. I've not had any problem till now. I set it up on a host where I've never used it before. When I go to the page- just browsing, not logged in yet, I get this error: Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/vhosts/MYSITE.com/httpdocs/datatube/security/MYsecurity.php:1) in /var/www/vhosts/MYSITE.com/httpdocs/datatube/security/MYsecurity.php on line 81 In the first place, I used the code from a site I just set up a few weeks ago (that doesn't show this error). I've used a program to compare to compare this file to the last one I set up. Other than the obvious differences in DB/Table/field names (that I've verified), there are no structural differences. Any guesses on why on one(many) host(s), this would work "perfectly", then on another host, it would break? Is it site structure? The way they handle something else? I'm reluctant to post the code for several reasons; 1- I've verified that there are no differences that should matter 2- There are several pages of code. 3- There are portions that I would have to significantly edit to post. So I'm just trying to see if anyone has any ideas why this might be happening, or suggest something to ask Tech Support?
  10. You nailed it dude. THAT fixed it all. HUGE thanks to you for your continued efforts to solve this!!
  11. This version returns a blank page. (Thanks for your continued efforts!!
  12. Sort of. When the page loads normally, the results are correct. (There are 3 feedback records and 2 test records- they are all INactive) When I click, "view active only", I get the 3 feedback records There should be none And when I click, "view inactive only", I get all 5records == Just to test, I made one FEEDBACK record Active. "view inactive only", I still get all 5 records "view active only" returns the same 3 feedback records (Even though only 1 is active.
  13. slowly, but surely we sneak up on it. For the fields, I'm using...$default_event= array('feedback', 'test'); I get the five results I expect when the page is run. When I click, "view active only", I get the three feedback records (that are still inactive) The top ECHO is: SELECT * FROM birthdays WHERE Event='feedback' OR Event='test' AND Active='1' And when I click, "view inactive only", I get all five records (that are still inactive) The top ECHO is: SELECT * FROM birthdays WHERE Event='feedback' OR Event='test' AND Active='0'
  14. I may have been premature. The query works for the initial display, but when you choose the "view inactive" or "view acive" links, I get the error again == 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 'Active='0'' at line 1 With Query: SELECT * FROM birthdays WHERE Event='feedback' OR Event='test' Active='0' (Or Active=1 when Active was the choice) === AND...in order to show my TOTAL noobness, I cannot figure out where you are ECHOing the select statement. I don't want to remove it, just comment it out.
  15. ECHO at top said: SELECT * FROM birthdays WHERE Event='feedback' OR Event='test' AND it returned the 5 results we were looking for!! And when I added the third choice, that also appeared to work. Thanks!!!!! I call this solved!!
  16. Result: 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 'OR Event='test'' at line 1 With Query: SELECT * FROM birthdays WHERE Event='feedback' AND OR Event='test'
  17. pocobueno, Thanks for your post. I really appreciate you working on this! We've made progress. The page no longer fails, but displays no results. I changed your array line to: $default_event= array('feedback', 'test'); As I know that should return five records (2 for test, 3 for feedback). FWIW, at the bottom of the page, after parsing the results in a "while ($row = mysql_fetch_assoc($result))..." loop, I ECHO: echo "<P>Total Records: $i</P>"; and it returns "2", and if I add a third event, it displays "3", but still no records display.
  18. Seeing no responses/help... can someone tell me if it's even possible?? Or if not, please tell me.
  19. I had a "PHP Guy" write some code for me that selects a type of event from my table. It works great. I can reproduce the page and change the expected field value in the line shown below and that page will then pull the records corresponding to that event. Line 30 is: $default_event='test'; So this would return all the records with "test" in my table. I would like to alter this line to select multiple events. I've tried just adding a comma and the next event like: $default_event='test,request'; but I get NO records when I do that. This is all the code that selects the records. Later we display them. I just need help on changing this to be able to select multiples at once. <?php include("dbinfo.inc.php"); mysql_connect(mysql,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $default_event='test'; /////THIS IS THE LINE FROM THE QUESTION*****************// if(isset($_REQUEST['changed']) && count($_REQUEST['changed']) > 0 && !empty($_REQUEST['command'])) { $sql = ""; $insql = "IN('" . join("','",array_keys($_REQUEST['changed'])) . "')"; switch($_REQUEST['command']) { case "Deactivate": $sql = "UPDATE birthdays SET ACTIVE='0' WHERE id " . $insql; break; case "Activate": $sql = "UPDATE birthdays SET ACTIVE='1' WHERE id " . $insql; break; case "Delete": $sql = "DELETE FROM birthdays WHERE id " . $insql; break; } if(!empty($sql)) { mysql_query($sql); } } $where = $url = array(); if(!empty($_REQUEST['event'])) { $where[] = "Event='" . addslashes($_REQUEST['event']) . "'"; $url[] = "event=" . $_REQUEST['event']; } else { $where[] = "Event='$default_event'"; $_REQUEST['event'] = $default_event; } if(strlen($active) > 0) { $where[] = "Active='" . addslashes($_REQUEST['active']) . "'"; $url[] = "active=" . $_REQUEST['active']; switch($active) { case 1: $page_type = "ACTIVE"; break; case 0: $page_type = "INACTIVE"; break; } } else { $page_type = "ALL"; } $query="SELECT * FROM birthdays"; if(count($where) > 0) { $query .= " WHERE " . join(" AND ",$where); } $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<A name=\"top\"></A><b><center><H1>Display Records \"<I>$page_type $default_event records</I>\":</H1>"; ?>
  20. Hoky-doky. I tried creating the MySQL function. I went to the "SQL" tab in PHPmyAdmin. (The Yahoo server I'm working on (no choice) is: phpMyAdmin 2.6.3) Once in the SQL tab, I typed in your code with changes: (My db name is "contacts", table is "birthdays" and the field I need to work on is "Cbirthdate" -for the record) DELIMITER $$ DROP FUNCTION IF EXISTS `contacts`.`fnAge`$$ CREATE FUNCTION `contacts`.`fnAge`(dob DATE) RETURNS int BEGIN DECLARE a int; SET a = YEAR(CURDATE()) - YEAR(dob); SET a = CASE DATE_FORMAT(CURDATE(),'%m%d') < DATE_FORMAT(dob,'%m%d') WHEN true THEN a-1 ELSE a END ; RETURN a; END$$ DELIMITER ; However PHPmyAdmin says: #1064 - 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 'DELIMITER $$ DROP FUNCTION IF EXISTS `contacts`.`fnAge`$$ CR ??
  21. Thanks for clarifying! Just for kicks then.... back to the original question that we've now rabbit-trailed off at least 54 times.... How can I put this in my page code to get me the Lowest age: Average age: Oldest age: I cant put "SELECT fnAge ('1949-01-22')" in my query can I? That would always return the same thing. I can connect to the table. What would be next then?
  22. So the SQL thing stays "within" PHPmyAdmin for use anytime, or am I missing it? Then your query code... is this also from within PHPmyAdmin? or out at the browser level on a page?
  23. Barand, Good to hear from you again. Can you tell me what the MySQL code does?
  24. LG: NP. I just wasn't sure. Well the good news is that I have no "Invalid" records per your test. I do have a bunch of blanks. How can I modify that code to return the record number with the rows? I don't see a counter. And/or... modify it to JUST return the rows with NO value in that field?
×
×
  • 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.