redarrow Posted March 16, 2007 Share Posted March 16, 2007 i was just inplementing a blog system and i needed to get information from one select staement from the same one so i got it going. can you tell me why it works please cheers. <?php session_start(); $query="select * from blogs where date_added=".$_GET['date_added']." and id=".$_GET['id']." "; $result=mysql_query($query); while($rec=mysql_fetch_assoc($result)){ // echo what ever } $query="select * from blogs where date_added=". $_GET['date_added']." and id=".$_GET['id']." "; $result=mysql_query($query); while($rec=mysql_fetch_assoc($result)){ ?> <?php $select1=" select * from blog_comments"; $t=mysql_query($select1); while($m=mysql_fetch_assoc($t)){ $select=" select * from blog_comments where user_blog_id='".$rec['id']."' and user_blog_date='".$rec['date_added']."' and date_added='".$m['date_added']."' and id='".$m['id']."' "; $res=mysql_query($select); while($dat=mysql_fetch_assoc($res)){ echo $dat['blog_comment']; } } } } ?> Link to comment https://forums.phpfreaks.com/topic/43051-what-sort-of-goin-is-it-cheers/ Share on other sites More sharing options...
shaunrigby Posted March 16, 2007 Share Posted March 16, 2007 1 thing i want to know, why you executing the same script twice? also, did you write this script because you are vunerable to SQL INJECTION ATTACKS! Link to comment https://forums.phpfreaks.com/topic/43051-what-sort-of-goin-is-it-cheers/#findComment-209113 Share on other sites More sharing options...
redarrow Posted March 16, 2007 Author Share Posted March 16, 2007 The reason for exec the script twice is becouse this is not the whole code ok the code is 1500 lines long ok, What you can see is the in and out of php for html. And yes i wrote the code. And how can there be any database attacks when the $_GETS[''] are all fully protected with a condition ok. only want to no what sort of sql statement this is? Link to comment https://forums.phpfreaks.com/topic/43051-what-sort-of-goin-is-it-cheers/#findComment-209121 Share on other sites More sharing options...
redarrow Posted March 16, 2007 Author Share Posted March 16, 2007 I must also add that the code provided is not the full code ok so no it dosent need correcting i need only to no why the select statement works. Link to comment https://forums.phpfreaks.com/topic/43051-what-sort-of-goin-is-it-cheers/#findComment-209127 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.