corillo181 Posted January 4, 2007 Share Posted January 4, 2007 why isn't this code working?[code]<? $see=mysql_query("SELECT today,user_id FROM tra_music_voted WHERE user_id='".$artist['artist_id']."' AND user_id='$user_id'")or die(mysql_error());$getdate=mysql_fetch_array($see);$today=date("F j, Y");$yesterday=$getdate['date'];$id=$getdate['user_id'];if(($yesterday==$today) && ($id==$user_id) ){echo "thank you for voting";}else{?> <li><a href="cu.php?vote=<?=$artist['artist_id']?>">vote</a> </li><?}?>[/code] Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted January 4, 2007 Share Posted January 4, 2007 Are you connected to your MySQL server?As well, your link has <?=$artist['artist_id']?>, the = may be killing it. Turn that = into a space, as well as a space after the ]. Quote Link to comment Share on other sites More sharing options...
SharkBait Posted January 4, 2007 Share Posted January 4, 2007 How is it not working? Are you getting an error? Quote Link to comment Share on other sites More sharing options...
corillo181 Posted January 4, 2007 Author Share Posted January 4, 2007 yeah everything that is in this code is working. is a page i got running with alot more codes and everything is working fine..but with this one i always get the the else statment. never the if. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted January 4, 2007 Author Share Posted January 4, 2007 alright sorry on the variable i got ['date'] instead of today.. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted January 4, 2007 Author Share Posted January 4, 2007 but this code i'm still having problem with.. if ther eis no record to update it wont insert a new record..[code]$updvoted=mysql_query("UPDATE tra_music_voted SET today='$today' WHERE artist_id='".$_GET['voted']."' AND user_id='$user_id'");if(!$updvoted){$today=date("F j, Y");$insertuser=mysql_query("INSERT into tra_music_voted(artist_id,user_id,today)VALUE('".$_GET['vote']."','$username','$today')")or die(mysql_query());}[/code] Quote Link to comment Share on other sites More sharing options...
corillo181 Posted January 4, 2007 Author Share Posted January 4, 2007 i think part of the reason why the code si not working is because it says that the code ahs takena ction even when there is no record to update it says tha tit has updated the record i found out but using this code..[code]$updvoted=mysql_query("UPDATE tra_music_voted SET today='$today' WHERE artist_id='".$_GET['voted']."' AND user_id='$user_id'");if($updvoted){echo "done";}else{echo "not done";}[/code]it echos out done.when there is no record at all in the tables..any one knows how i could fix this? Quote Link to comment Share on other sites More sharing options...
corillo181 Posted January 4, 2007 Author Share Posted January 4, 2007 done all i had to do was use mysql_num_rows to see if any row was effected if not them to insert a new one..i seen to be talking to my self here :D 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.