Hey guys, I am trying to update an image SRC but I need a little help. This is what I have so far: update.php <?php include_once("viewitem.php"); include_once("../config.inc.php"); include_once("../db_connect.php"); // get vars $j = $_REQUEST['j']; $newimg = $_REQUEST['newimg']; if($submitmetwo) { $query="UPDATE tracks SET email='$newimg' WHERE id='$j'"; mysql_query($query); echo "Record Updated"; mysql_close(); } ?> PHP: viewitem.php <?php include_once("../config.inc.php"); include_once("../db_connect.php"); // get vars $j = $_REQUEST['j']; $r = $_REQUEST['r']; $get_info = mysql_query("SELECT * FROM tracks WHERE id = ".$j." LIMIT 1"); if($get_info) { $artist = mysql_result($get_info, 0, artist); $title = mysql_result($get_info, 0, title); $album = mysql_result($get_info, 0, album); if(strlen($album) == 0) $album = "Unknown"; $lyrics = mysql_result($get_info, 0, lyrics); $dateadded = mysql_result($get_info, 0, dateadded); $emailadd = mysql_result($get_info, 0, email); $userip = mysql_result($get_info, 0, ip); $ptitle = substr($joke, 0, 50).""; $meta_keys = ""; $meta_desc = ""; $selected = "VIEW"; include("../header1.php"); ?> <table width="100%" cellspacing="5" cellpadding="0"> <tr> <td> <form method="post" action="update.php"><input type="hidden" name="submitmetwo" value="yes"> <font size='2.5'>New IMG : </font><input type="text" id="textarea" name="newimg" class="form" style="width:130px;" value="<?php echo stripslashes($newimg); ?>"> <input type="submit" id="submitbutton" value="SUBMIT" class="form"> </form> </td> <td valign="top"> <?php echo "<table width='100%' cellspacing='0' cellpadding='0'>"; echo "<form method='POST' action='index.php'><input name='item' type='hidden' value='".$j."'><tr><td colspan='2'><b>"; if($r == 1) echo "Random"; else echo "Viewing"; echo " Profile Of ".$artist.":</b><br><br></td><td></td></tr>"; echo "<tr><td width='90'><font class='listingtitle'>Listing:</font></td><td>".$artist."</td><td rowspan='9' valign='top'> </td></tr>"; echo "<tr><td style='padding-top:4px;'></td><td> </td></tr>"; echo "<tr><td width='90'><font class='listingtitle'>Nickname:</font></td><td>".$album."</td></tr>"; echo "<tr><td style='padding-top:4px;'></td><td> </td></tr>"; echo "<tr><td width='90'><font class='listingtitle'>Category:</font></td><td>".$title."</td></tr>"; echo "<tr><td style='padding-top:4px;'></td><td> </td></tr>"; echo "<tr><td style='padding-top:4px;'><font class='listingtitle'>Date Added:</font></td><td style='padding-top:4px;'>".$dateadded."</td></tr>"; echo "<tr><td style='padding-top:4px;'></td><td> </td></tr>"; echo "<tr><td valign='top' style='padding-top:4px;'><font class='listingtitle'>Country:</font></td><td valign='top' style='padding-top:4px;'>".$lyrics."</td></tr>"; if ( $emailadd == "" ) { echo ""; } else { echo "<tr><td>Image:</td><td><div align='center'><IMG SRC='$emailadd' height='' width='375'></center></td></tr>"; } echo "<tr><td style='padding-top:4px;'></td><td> </td></tr>"; $this_url = $site_path."view-".$j."-".urlconvert($artist)."_".urlconvert($title).".php"; $this_title = $title." - ".$artist." "; echo "<tr><td valign='top' style='padding-top:24px;'></td><td valign='top' style='padding-top:24px;'><input name='approve' value='keep' type='submit'> <input name='decline' value='delete' type='submit'></td></tr>"; echo "</form></table>"; ?> </td> </tr> </table> <?php } ?> <?php include("footer.php"); ?> PHP: When I enter a value into the "newimg" textbox and press submit it redirects to update.php but nothing happens and nothing executed. Any help on how to get this working?? Thanks! By the way this is the "newimg" text box that I have written and am refering too. It is also in the above code:
'j' is not defined in HTML. You are trying to retrieve 'j' from $_REQUEST but since it is not available in HTML, you would be getting it blank and hence UPDATE query is not updating any row. Is there something I have overlooked or 'j' is present in HTML but not in code snippet you gave?
Thanks for the help! I updated the code but it is still not working. I get the text "Record Updated" but the records don't get updated. Here is what I have now: In the viewitem.php update.php I have been playing with this for 4 hours and still can't get it! Please helpp! Thanks!
I think you are not getting a value for $artist in update.php. Check whether you are getting a value for $artist. then updation will be ok.
Still didn't work I think the problem exists within locating the files but I don't really know how to to that. I tried incorporating the update into viewitem but the same thing happens and nothing gets updated.
try replacing query with this $query1 = "UPDATE tracks SET email = '".$newimg."' WHERE artist = '".$artist."' ";
Still didn't work This shouldn't be that complicated, I think I am messing up on something really simple too. The "Record updated" states but nothing gets updated. Thanks for the help though
Thx for the help =) I just ran the Update sql in phpMyAdmin and it worked for inputing the values, my guess is it just doesn't know what "artist" is in my code, but I can't declare what artist is because it requires a mysql_query function.
There's always many mistakes with ' or " or / in mysql and php codes... so be aware of not making them