Jump to content

More Header fun...


Grant Holmes

Recommended Posts

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

Link to comment
Share on other sites

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.
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>";
?>

Link to comment
Share on other sites

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());
?>

 

??

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.  :D

Link to comment
Share on other sites

I'm a newbie, but yes, the include IS there!!  :D

 

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.