-
Posts
2,527 -
Joined
-
Last visited
Everything posted by DeanWhitehouse
-
session_start(); need that at the begging of the code. on the first line
-
if(isset($_GET['image_cat']) && $_GET['image_subcat'])
DeanWhitehouse replied to DeanWhitehouse's topic in PHP Coding Help
ok, anyone got any ideas, i need to have main catergory's and then sub catergorys in it. this is my database structure 3 tables image_gallery ( image_id folder_name image_name img_time image_link filename sub_folder ) image_catergory ( catergory image_link ) sub_cat ( sub_cat parent_cat imagelink ) this is my code, to display this , but i can't get it right <?php require_once 'header.php'; $time_stamp = date("d.m.Y"); $date = $time_stamp; ///////////////////////////////////////////////////////////// if(isset($_GET['image_cat']) && isset($_GET['image_subcat'])) // If the URL ends in ?image_cat do everything in the brakets { $cat = $_GET['image_cat']; $sub_cat = $_GET['image_subcat']; $check = "SELECT sub_cat FROM sub_cat WHERE `parent_cat` = '{$cat}'"; $check2 = mysql_query($check) or die ("Error:" . mysql_error()); $rom = mysql_fetch_assoc($check2); $cat2 = $rom['sub_cat']; $query = "SELECT folder_name,image_link,image_id,image_name,sub_folder FROM `image_gallery` WHERE `sub_folder` = '{$cat2}' ORDER BY image_id ASC"; $result = mysql_query($query) or die("Error:" . mysql_error()); $i = 0; ?> <table align="center"><tr> <?php while ($row = mysql_fetch_assoc($result)) { if ($i == 4) { $i = 0; // reset variable echo "</td></tr><tr></tr><tr><td>"; // break the line } ?><a href="<?php echo $row['image_link']; ?>" rel="lightbox [main]" title="<?php echo $row['image_name']; ?>" ><img width="150px" src="<?php echo $row['image_link']; ?>"></a></td><td> <?php $i++; // increase $i each time through the loop } ?> </td></tr></table> <?php require_once 'footer.php'; exit(); } ///////////////////////////////////////////////////////////// if(isset($_GET['image_cat'])) // If the URL ends in ?image_cat do everything in the brakets { $i = $_GET['image_cat']; $que = "SELECT sub_cat FROM sub_cat WHERE `parent_cat` = '{$i}'"; $resu = mysql_query($que) ; $query = "SELECT catergory FROM `image_catergory` ORDER BY catergory ASC"; $result = mysql_query($query) ; $sql = "SELECT * FROM sub_cat WHERE `imagelink`='{$subcate}' ORDER BY RAND() LIMIT 1"; $reslt = mysql_query($sql); $rw = mysql_fetch_assoc($reslt); $wo = mysql_fetch_assoc($result); $subcate = $rw['sub_cat']; $i = 0; ?> <table align="center"><tr> <?php while ($row = mysql_fetch_assoc($resu)) { if ($i == 4) { $i = 0; // reset variable echo "<tr>"; // break the line } ?><td><font style="font-size:large"><b><?php echo $row['sub_cat'] ?></b></font><br><a href="?image_cat=<?php echo $wo['catergory']; ?>&image_subcat=<?php echo $row['sub_cat']; ?>"><img width="150px" src="<?php echo $row['imagelink']; ?>"></a></td><td> </td> <?php $i++; // increase $i each time through the loop } ?> </td></tr></table> <?php if (mysql_num_rows($resu) < 1) { echo "No Images Yet. <br>Keep Checking Backs<br>"; } exit(); } ///////////////////////////////////////////////////////////// //No ID passed to page, display user list: $query = "SELECT catergory,image_link FROM `image_catergory` ORDER BY catergory ASC"; $result = mysql_query($query) ; $sql = "SELECT * FROM image_catergory WHERE `image_link`='{$cate}' ORDER BY RAND() LIMIT 1"; $reslt = mysql_query($sql); $rw = mysql_fetch_assoc($reslt); $cate = $row['catergory']; $i = 0; ?> <table align="center"><tr> <?php while ($row = mysql_fetch_assoc($result)) { if ($i == 4) { $i = 0; // reset variable echo "<tr>"; // break the line } ?><td><font style="font-size:large"><b><?php echo $row['catergory'] ?></b></font><br><a href="?image_cat=<?php echo $row['catergory']; ?>"><img width="150px" src="<?php echo $row['image_link']; ?>"></a></td><td> </td> <?php $i++; // increase $i each time through the loop } ?> </td></tr></table> <?php if (mysql_num_rows($result) < 1) { echo "No Images Yet. <br>Keep Checking Back<br>"; } require_once 'footer.php'; ?> i would do the database, but i can't seem to get it working now. ANY HELP PLEASEEE -
if(isset($_GET['image_cat']) && $_GET['image_subcat'])
DeanWhitehouse replied to DeanWhitehouse's topic in PHP Coding Help
anyone , have any ideas? -
if(isset($_GET['image_cat']) && $_GET['image_subcat'])
DeanWhitehouse replied to DeanWhitehouse's topic in PHP Coding Help
$query = "SELECT folder_name,image_link,image_id,image_name,sub_folder FROM `image_gallery` WHERE `folder_name` = '{$cat}' AND `sub_folder` = '{$sub_cat}' ORDER BY image_id ASC"; $result = mysql_query($query) or die("Error:" . mysql_error()); and yes , just echoed them out and they are correct. -
if(isset($_GET['image_cat']) && $_GET['image_subcat'])
DeanWhitehouse replied to DeanWhitehouse's topic in PHP Coding Help
erm, ok well this is some of the code <?php $cat = $_GET['image_cat']; $sub_cat = $_GET['image_subcat']; $query = "SELECT folder_name,image_link,image_id,image_name,sub_folder FROM `image_gallery` WHERE `sub_folder` = '{$sub_cat}' ORDER BY image_id ASC"; $result = mysql_query($query) or die("Error:" . mysql_error()); //$qry = "SELECT folder_name,image_link,image_id,image_name,sub_folder FROM `image_gallery` WHERE `folder_name` = '{$cat}' ORDER BY image_id ASC"; //$reslt = mysql_query($qry) or die("Error:" . mysql_error()); //$rw = mysql_fetch_assoc($reslt) $i = 0; ?> ok, well it is for a subcatergory in a image gallery, but it isn't selecting from the actual main catergory only the sub, and when i add the AND. The page doesn't show any image -
if(isset($_GET['image_cat']) && $_GET['image_subcat'])
DeanWhitehouse replied to DeanWhitehouse's topic in PHP Coding Help
ok, that now works. But how can i get this to work. $query = "SELECT folder_name,image_link,image_id,image_name,sub_folder FROM `image_gallery` WHERE `sub_folder` = '{$sub_cat}'ORDER BY image_id ASC"; when i add a AND to it , it doesn't work. e.g. $query = "SELECT folder_name,image_link,image_id,image_name,sub_folder FROM `image_gallery` WHERE `sub_folder` = '{$sub_cat}' AND `folder_name` = '{$cat}' ORDER BY image_id ASC"; -
if(isset($_GET['image_cat']) && $_GET['image_subcat'])
DeanWhitehouse replied to DeanWhitehouse's topic in PHP Coding Help
ok, but can i get both of these from it, using $_GET['']; -
Is this the correct syntax for to check two things in a $_GET statement if(isset($_GET['image_cat']) && $_GET['image_subcat']) the address will be ?image_cat=landscape&image_subcat=test and i need it to check both of these, this is the rest of my code <?php if(isset($_GET['image_cat']) && $_GET['image_subcat']) // If the URL ends in ?image_cat do everything in the brakets { $cat = $_GET['image_cat']; $sub_cat = $_GET['image_subcat']; $query = "SELECT folder_name,image_link,image_id,image_name,sub_folder FROM `image_gallery` WHERE `folder_name` = '{$cat}' AND `sub_folder` = '{$sub_cat}' ORDER BY image_id ASC"; $result = mysql_query($query) or die("Error:" . mysql_error()); $i = 0; ?> <table align="center"><tr> <?php while ($row = mysql_fetch_assoc($result)) { if ($i == 4) { $i = 0; // reset variable echo "</td></tr><tr></tr><tr><td>"; // break the line } ?><a href="<?php echo $row['image_link']; ?>" rel="lightbox [main]" title="<?php echo $row['image_name']; ?>" ><img width="150px" src="<?php echo $row['image_link']; ?>"></a></td><td> <?php $i++; // increase $i each time through the loop } ?> </td></tr></table> <?php require_once 'footer.php'; exit(); } ///////////////////////////////////////////////////////////// if(isset($_GET['image_cat'])) // If the URL ends in ?image_cat do everything in the brakets { $i = $_GET['image_cat']; $que = "SELECT sub_cat,imagelink FROM `sub_cat` ORDER BY sub_cat ASC"; $resu = mysql_query($que) ; $query = "SELECT catergory FROM `image_catergory` ORDER BY catergory ASC"; $result = mysql_query($query) ; $sql = "SELECT * FROM sub_cat WHERE `imagelink`='{$subcate}' ORDER BY RAND() LIMIT 1"; $reslt = mysql_query($sql); $rw = mysql_fetch_assoc($reslt); $wo = mysql_fetch_assoc($result); $subcate = $rw['sub_cat']; $i = 0; ?> <table align="center"><tr> <?php while ($row = mysql_fetch_assoc($resu)) { if ($i == 4) { $i = 0; // reset variable echo "<tr>"; // break the line } ?><td><font style="font-size:large"><b><?php echo $row['sub_cat'] ?></b></font><br><a href="?image_cat=<?php echo $wo['catergory']; ?>&image_subcat=<?php echo $row['sub_cat']; ?>"><img width="150px" src="<?php echo $row['imagelink']; ?>"></a></td><td> </td> <?php $i++; // increase $i each time through the loop } ?> </td></tr></table> <?php if (mysql_num_rows($resu) < 1) { echo "No Images Yet. <br>Keep Checking Backs<br>"; } exit(); } ?>
-
ok, this one seems to work $res = mysql_query("SELECT * FROM darkflame_gallery WHERE image_id='{$checked}'") or die ("Error:" . mysql_error()); $r = mysql_fetch_assoc($res); mysql_query("DELETE FROM darkflame_gallery WHERE image_id='{$checked}'") or die("Error:" . mysql_error()); $myFile = "images/".$r['filename']; if(!file_exists($myFile)) die("File doesn't exist: '{$myFile}'"); if(!is_writable($myFile)) die("File isn't writable: '{$myFile}'"); unlink($myFile) or die("Can't delete file: '{$myFile}'");
-
Warning: unlink(/images/) [function.unlink]: No such file or directory in .... i get that error with this code $res = mysql_query("SELECT * FROM darkflame_gallery WHERE image_id='{$checked}'") or die ("Error:" . mysql_error()); $r = mysql_fetch_assoc($res); mysql_query("DELETE FROM darkflame_gallery WHERE image_id='{$checked}'") or die("Error:" . mysql_error()); $myFile = "/images/".$r['filename']; unlink($myFile) or die("can't open file");
-
that all works fine, it is the unlink that isn;t working
-
ok, so this is my code <?php mysql_query("DELETE FROM darkflame_gallery WHERE image_id='{$checked}'") or die("Error:" . mysql_error()); $qu = "SELECT * FROM darkflame_gallery WHERE image_id='{$checked}'"; $res = mysql_query($qu) or die ("Error:" . mysql_error()); $r = mysql_fetch_assoc($res); $myFile = "../images/".$r['filename']; $fh = fopen($myFile, 'w') or die("can't open file"); fclose($fh); $filename = $r['filename']; unlink($filename); ?> but it is trying to delete the image from admin_area.php, not the folder is ay any ideas?
-
change this echo "<script language='javascript'>window.location='http://www.google.com/';</script>"; to header ("http://google.com"); then put ob_start(); at the begining of the script
-
erm i think, i am not that experienced but , the basic idea would be //page 1 contain something really important e.g. a session (have this encrypted) // then on each page put // copyright // then at the begining of each page check for the session if it is not there, then they have removed something that kinda idea
-
have one file that has something that is required for the page to run, then in the copyright bit have a require ''; for that file , then encrypt the copyright piece of code, and then if they delete the code there pages will display an error
-
[SOLVED] Silly problem with comparison of IP
DeanWhitehouse replied to waynew's topic in PHP Coding Help
try this if($result == $ip) { header('Location:http://*************.com/ban.php'); } -
from what i know you need to use a loop , and a cron job to change the image every week, the loop is to show it . How are you displaying the links?
-
This is not related to PHP, this is related to Dreamweaver. Please Post In the Appropiate forum. P.S. try google
-
Feeling like a dumb ass, please help :)
DeanWhitehouse replied to think-digitally's topic in PHP Coding Help
i have a code that does what you want, do u want that? -
[SOLVED] how can i do this!!! mysql question
DeanWhitehouse replied to DeanWhitehouse's topic in PHP Coding Help
lol, yer soz, i didn't check it, but my table is called that -
How can i have it so that my page looks like this catergory1 | catergory2 | catergory3 imagefromcat1|imagefromcat2|imagefromcat3 i already it on the correct rows, etc. but it shows catergory1 | catergory1 | catergory1 imagefromcat1|imagefromcat1|imagefromcat1 this is my code <?php $query = "SELECT image_id, image_name, image_link, folder_name,img_time FROM `darkflame_gallery`"; $result = mysql_query($query) or die("Error:" . mysql_error()); $qery = "SELECT catergory FROM `darkflame_catergory`"; $rsult = mysql_query($qery) or die("Error:" . mysql_error()); $s = mysql_fetch_assoc($rsult); $sql = "SELECT * FROM darkflame_gallery WHERE `folder_name`='{$cate}' ORDER BY RAND() LIMIT 1"; $reslt = mysql_query($sql) or die ("Error:" . mysql_error()); $rw = mysql_fetch_assoc($reslt); $cate = $row['folder_name']; $i = 0; ?> <table><tr> <?php while ($row = mysql_fetch_assoc($result)) { if ($i == 4) { $i = 0; // reset variable echo "<tr>"; // break the line } ?><td><?php echo $s['catergory'] ?><br><a href="?image_cat=<?php echo $row['catergoy']; ?>"><img width="200px" src="<?php echo $rw['image_link']; ?>"></a> <?php $i++; // increase $i each time through the loop } ?> </td></tr></table>
-
e.g. if(isset($_GET['test'])) { //this is what happens when the URL ending is ?test }
-
how can i get it to show line like this |title| name1|name2|name3| image1|image2|image3| i tried this //No ID passed to page, display user list: $query = "SELECT image_id, image_name, image_link, folder_name,img_time FROM `darkflame_gallery`"; $result = mysql_query($query) or die("Error:" . mysql_error()); $i = 0; ?> <table><tr><td> <?php while ($row = mysql_fetch_assoc($result)) { if ($i == 4) { $i = 0; // reset variable echo "<BR>"; // break the line } echo "<b>".$row['img_time']."</b></td></tr><tr><td>"; ?><a href="?image_id=<?php echo $row['image_id']; ?>"><?php echo $row['image_name']; ?></a> <?php $i++; // increase $i each time through the loop } ?> </td></tr></table> do i need to have two seperate echo's? or two while loops?