kenrbnsn Posted February 7, 2008 Share Posted February 7, 2008 Grant - its not related to your query, but I notice you are using an XHTML doctype. As a result, you need to make all your tag names all small letters. Capital letters are invalid code in XHTML. No, the OP is not using XHTML, at least not in the latest version that was posted: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> Ken Quote Link to comment Share on other sites More sharing options...
haku Posted February 7, 2008 Share Posted February 7, 2008 No, the OP is not using XHTML, at least not in the latest version that was posted: You're right! I even double checked that before posting it. I must be tired Quote Link to comment Share on other sites More sharing options...
Grant Holmes Posted February 7, 2008 Author Share Posted February 7, 2008 Thought if I posted the error it might help. Parse error: parse error, unexpected $ in /var/www/vhosts/MySite.com/httpdocs/datatube/songs_edit.php on line 141 Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 7, 2008 Share Posted February 7, 2008 That is telling you that you have unclosed loops -- you're missing the closing "}" on one or more loops. PHP is looking to close the loops, but found the end of the file instead -- it's a lousy error message. Ken Quote Link to comment Share on other sites More sharing options...
Grant Holmes Posted February 7, 2008 Author Share Posted February 7, 2008 See: 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."'"; } // I added this, but this just moved the error down one row. ?> Quote Link to comment Share on other sites More sharing options...
Grant Holmes Posted February 7, 2008 Author Share Posted February 7, 2008 bump Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 7, 2008 Share Posted February 7, 2008 If you compare the original code you posted to the last code you post, you'll see you're missing these two lines: <?php $result=mysql_query($query); header("Location: song_list.php?id=".$ud_id); } ?> at the end of the first while loop. Ken Quote Link to comment Share on other sites More sharing options...
phpSensei Posted February 7, 2008 Share Posted February 7, 2008 What is line 140? Quote Link to comment Share on other sites More sharing options...
Grant Holmes Posted February 7, 2008 Author Share Posted February 7, 2008 So I know we're all on the same page now.... The page displays, there are no errors showing, but no changes are saved to the table. Here's where I am: <?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; ?>"> <BR> 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>"; ?> Quote Link to comment Share on other sites More sharing options...
phpSensei Posted February 7, 2008 Share Posted February 7, 2008 add $result=mysql_query($query) or die(mysql_error()); to your querys Quote Link to comment Share on other sites More sharing options...
Grant Holmes Posted February 7, 2008 Author Share Posted February 7, 2008 So you're saying here: <?php $query='SELECT * FROM SongList where id = "'.$id.'"'; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<H1>Edit Song Details</H1>"; ?> Do this?? <?php $query='SELECT * FROM SongList where id = "'.$id.'"'; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<H1>Edit Song Details</H1>"; $result=mysql_query($query) or die(mysql_error()); ?> ?? Quote Link to comment Share on other sites More sharing options...
phpSensei Posted February 7, 2008 Share Posted February 7, 2008 Yes, it is what I am saying. Quote Link to comment Share on other sites More sharing options...
Grant Holmes Posted February 7, 2008 Author Share Posted February 7, 2008 Okay, so I found that one place where it wasn't and one place where the "DIE" part was missing. So now my code is: <?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) or die(mysql_error()); // **********added the 'die' here 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>"; $result=mysql_query($query) or die(mysql_error());// ***********added whole line here ?> <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; ?>"> <BR> 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> <?php ++$i; } echo "</table><BR>"; ?> Now when I hit the page I get: Warning: mysql_query(): Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/vhosts/MYSITE.com/httpdocs/datatube/songs_edit.php on line 52 Warning: mysql_query(): A link to the server could not be established in /var/www/vhosts/MYSITE.com/httpdocs/datatube/songs_edit.php on line 52 Access denied for user 'apache'@'localhost' (using password: NO) Quote Link to comment Share on other sites More sharing options...
phpSensei Posted February 7, 2008 Share Posted February 7, 2008 @mysql_select_db($database) or die( "Unable to select database"); to mysql_select_db($database) or die( "Unable to select database"); Also make sure you mysql info is correct. Quote Link to comment Share on other sites More sharing options...
Grant Holmes Posted February 7, 2008 Author Share Posted February 7, 2008 "@" removed. And fixed two results/die statements. By "mysql info", do you mean the connection info? If so, yes I am. So, after all that, I'm back to a page without errors that doesn't save the results. sigh. Quote Link to comment Share on other sites More sharing options...
Grant Holmes Posted February 8, 2008 Author Share Posted February 8, 2008 Last bump. Anymore help gang? Quote Link to comment Share on other sites More sharing options...
aschk Posted February 8, 2008 Share Posted February 8, 2008 Yes, you're not supplying your connection with your query. (or your connection is failing, invalid authentication???, does that inc.php file exist?) Thus you need: $conn = mysql_connect("localhost","username","password"); mysql_query($query,$conn); Insert the above into the right places in your script. Quote Link to comment Share on other sites More sharing options...
Grant Holmes Posted February 8, 2008 Author Share Posted February 8, 2008 I'm a newbie, but yes, the include IS there!! So are you saying this goes into ANY query "open" I do??? In my line 11, I have: include("dbinfo.inc.php"); mysql_connect($dbhost,$username,$password); mysql_select_db($database) or die( "Unable to select database") To make sure I understand... change the above to: include("dbinfo.inc.php"); $conn = mysql_connect($dbhost,$username,$password); mysql_select_db($database) or die( "Unable to select database") mysql_query($query,$conn); Do I need to do this on every query? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 8, 2008 Share Posted February 8, 2008 The connection is optional in the mysql_query() call as stated in the PHP Manual The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If by chance no connection is found or established, an E_WARNING level warning is generated. Ken Quote Link to comment Share on other sites More sharing options...
Grant Holmes Posted February 8, 2008 Author Share Posted February 8, 2008 FWIW, I tried my edit and got a parse error. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.