Stuart_Westgate Posted May 28, 2013 Share Posted May 28, 2013 Is this code correct. If there's an errors or a better way of writting this can you please say? $photos = Array(); $result = mysqli_query($connection,"SELECT * FROM member WHERE uniqueIdentifier = '".$_POST['deviceID']."' AND currentDate = '".$_POST['matchDate']."'"); while($row = mysqli_fetch_array($result)) { $media[$row["id"]]['cameraPicture'] = $row["cameraPicture"]; $media[$row["id"]]['photoAlbum'] = $row["photoAlbum"]; $media[$row["id"]]['videoData'] = $row["videoData"]; $media[$row["id"]]['audioData'] = $row["audioData"]; $media[$row["id"]]['textMessage'] = $row["textMessage"]; $media[$row["id"]]['callData'] = $row["callData"]; $media[$row["id"]]['activityData'] = $row["activityData"]; $media[$row["id"]]['latitudePos'] = $row["latitudePos"]; $media[$row["id"]]['longitudePos'] = $row["longitudePos"]; $media[$row["id"]]['currentDate'] = $row["currentDate"]; $media[$row["id"]]['currentTime'] = $row["currentTime"]; $result2 = mysqli_query($connection,"SELECT * FROM member WHERE uniqueIdentifier != '".$_POST['deviceID']."' AND currentDate = '".$_POST['matchDate']."' OR latitudePos BETWEEN '".$_POST['latMin']."' AND '".$_POST['latMax']."' AND longitudePos BETWEEN '".$_POST['longMin']."' AND '".$_POST['longMax']."'"); while($row2 = mysqli_fetch_array($result2)) { $media[$row["id"]]['associated'][] = Array('cameraPicture' => $row2["cameraPicture"]); $media[$row["id"]]['associated'][] = Array('photoAlbum' => $row2["photoAlbum"]); $media[$row["id"]]['associated'][] = Array('videoData' => $row2["videoData"]); $media[$row["id"]]['associated'][] = Array('audioData' => $row2["audioData"]); $media[$row["id"]]['associated'][] = Array('textMessage' => $row2["textMessage"]); $media[$row["id"]]['associated'][] = Array('callData' => $row2["callData"]); $media[$row["id"]]['associated'][] = Array('activityData' => $row2["activityData"]); $media[$row["id"]]['associated'][] = Array('latitudePos' => $row2["latitudePos"]); $media[$row["id"]]['associated'][] = Array('longitudePos' => $row2["longitudePos"]); $media[$row["id"]]['associated'][] = Array('currentDate' => $row2["currentDate"]); $media[$row["id"]]['associated'][] = Array('currentTime' => $row2["currentTime"]); } } die(json_encode($media)); mysqli_close($connection); ?> Link to comment https://forums.phpfreaks.com/topic/278452-is-there-a-better-way-to-write-this-php-mysql-script/ Share on other sites More sharing options...
Barand Posted May 28, 2013 Share Posted May 28, 2013 If you look at your other post about these media arrays you'll see I already posted a better way. Are you planning many more posts on this same topic? Link to comment https://forums.phpfreaks.com/topic/278452-is-there-a-better-way-to-write-this-php-mysql-script/#findComment-1432641 Share on other sites More sharing options...
jeapie Posted May 28, 2013 Share Posted May 28, 2013 I recommend you to use PDO for Mysql. It's far more secure and modern way to work with DB Link to comment https://forums.phpfreaks.com/topic/278452-is-there-a-better-way-to-write-this-php-mysql-script/#findComment-1432670 Share on other sites More sharing options...
cyberRobot Posted May 28, 2013 Share Posted May 28, 2013 I recommend you to use PDO for Mysql. It's far more secure and modern way to work with DB Can you (or someone) clarify why PDO is inherently more secure than MySQLi? Link to comment https://forums.phpfreaks.com/topic/278452-is-there-a-better-way-to-write-this-php-mysql-script/#findComment-1432725 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.