fife
Members-
Posts
381 -
Joined
-
Last visited
Everything posted by fife
-
I have a looping table with a form within the loop. see below <table width="403" border="0" cellpadding="5"> <?php $i=0; do { ?> <tr> <td width="146"><?php echo $row_rs_foods['name']; ?></td> <td width="147"><?php echo $row_rs_foods['price']; ?></td> <td width="82"> <form action="" method="post"> <input name="idfood" type="hidden" value="<?php echo $row_rs_foods['idfoods']; ?>" /> <input name="adddish<?php echo $i;?>" type="submit" value="Add Meal" /> </form> </td> </tr> <?php $i++; } while ($row_rs_fooditem = mysql_fetch_assoc($rs_fooditem)); ?> </table> The query that inserts the form is as below <?php if(isset($_POST['adddish'])) { $food = mysql_real_escape_string($_POST['idfood']); $menu = $_GET['menu']; $course = $_GET['course']; $insertq = mysql_query("INSERT INTO foodlink (idmenu, idfood, course) VALUES ('$menu', '$food', '$course')") or die(mysql_error()); $url = "add-existing-foods.php"; header("Location: $url"); } ?> Now my submit button increments each time by 1 but I dont understand how to make the if(isset($_POST['adddish'])) { have the right number so the right food is inserted each time. Can someone please help?
-
Can someone please help with this if statement. Im having trouble breaking out of the echo do { echo" <table width='150' border='0'> <tr><td align='left' valign='top'> <a href='edit-page.php?page={$page['pageid']}'", if($page['status']==0){echo "class='inactive'"} ">{$page['pagename']}</a> </td></tr> </table>"; }while ($page = mysql_fetch_assoc($pagesq)); Getting told by my software I have an syntax error.
-
solved. it couldnt find the server root so adding {$_SERVER['DOCUMENT_ROOT']} at the start of the path solved the issue.
-
ok I managed to get myself some errors. Here is what I got Warning: getimagesize(/members/images/members/Merseyside/0b12dd48f09fafc2e2985743cca2029flazy-grass-2.jpg) [function.getimagesize]: failed to open stream: No such file or directory in/members/clubs/SimpleImage.php on line 30 Warning: imagesx(): supplied argument is not a valid Image resource in /members/clubs/SimpleImage.php on line 73 Warning: Division by zero in /members/clubs/SimpleImage.php on line 87 Warning: imagesy(): supplied argument is not a valid Image resource in /members/clubs/SimpleImage.php on line 77 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /members/clubs/SimpleImage.php on line 99 Warning: imagesx(): supplied argument is not a valid Image resource in /members/clubs/SimpleImage.php on line 73 Warning: imagesy(): supplied argument is not a valid Image resource in /members/clubs/SimpleImage.php on line 77 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /members/clubs/SimpleImage.php on line 100 Warning: imagejpeg(): supplied argument is not a valid Image resource in /members/clubs/SimpleImage.php on line 46
-
yes at the top of the page i put error_reporting(E_ALL); ini_set("display_errors", 1);
-
thanks requinix for your reply however that did not solve it. Still the same issues. No errors even with reporting and file is still the same size. The image is also definitely loading into the page as I have checked that too. Here is the code as stands $path = '/members/images/merseyside/'.$fetched['imageName'].''; include('SimpleImage.php'); $image = new SimpleImage(); $image->load($path); $image->resize(60,60); $image->save($path); $url = "/activity-photos.php?uploaded=true"; header("Location: $url");
-
Ok I have seen many posts on this script and many people asking question on this site. The script can be found..... http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/ However I still can not make it work with what I have got. So here is the problem. First of all I upload the image and save the name to the database. I then pass its ID to the next page to retrieve the image and its path from the database. This is where the script comes in. I then run the image through the script and send you to the success page. Now the image is not being resized! The code is not erroring (even with error reporting on). It would seem the code it just get ignored completely. The image is still there and displays how it was uploaded but the size just hasnt changed. Im asuming Im using it in the correct way. Here is the code after the image has been uploaded. $Fetchq = mysql_query("SELECT * FROM images WHERE imageID ='".$_GET['image']."' ") or die('error stuff here'); $fetched = mysql_fetch_array($Fetchq); $path = "/members/images/members/merseyside/{$fetched['imagename']}"; include('SimpleImage.php'); $image = new SimpleImage(); $image->load('$path'); $image->resize(60,60); $image->save('$path'); $url = "/activity-photos.php?uploaded=true"; header("Location: $url"); Any help would be greatly appreciated as I've had enough of banging my head against this code wall
-
Ok im going to try an give as much info as possible. Im using a plugin called jcapslide which can be found here http://tympanus.net/codrops/2009/11/23/jcapslide-a-jquery-image-caption-plugin/ Its a image caption plugin that is cross browser compatible. Now each of my images an their info are drawn through a php query and displayed on the page. I then use this jcapslide to display extra info. However!!!! In all versions of IE the plugin works great. In Google crome it works great. Now If I refresh my page in google crome each image in the list displays on top of one another, moves out of position and the caption plugin completely stops working as a result. Here is my code. thanks //first the query to get 6 images $Fetchactivityq = mysql_query("SELECT name, description, image FROM activities WHERE club ='".$club['club']."' ORDER BY RAND() LIMIT 6 ") or die('activity error'); $activitynum = mysql_num_rows($Fetchactivityq); //then the loop to display the images <?php $i = 0; while($row = mysql_fetch_assoc($Fetchactivityq)) { ?> <li id="capslide_img_cont<?php echo $i;?>" class="ic_container"> <img src="/images/icons/activityImage.jpg" id="activityImage" /> <div class="overlay" style="display:none;"></div> <div class="ic_caption"> <p class="ic_category"></p> <h3><a href="#"><?php echo $row['name']; ?></a></h3> <p class="ic_text"> <?php echo $row['description'];?> </p> </div> <?php } ?> // then the code at the bottom of the page for the caption <script src="/js/capslide/jquery.capSlide.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $("[id^='capslide_img_cont']").capslide({ caption_color : 'white', caption_bgcolor : 'black', overlay_bgcolor : 'black', border : '', showcaption : true }); }); </script> you also have to include some styles so here are the default styles .ic_container{ vertical-align:baseline; margin:10px; position:relative; /*-moz-border-radius:10px; -webkit-border-radius:10px; -khtml-border-radius:10px; -moz-box-shadow: 0 1px 3px #888; -webkit-box-shadow: 0 1px 3px #888;*/ } .overlay{ opacity:0.3; position:absolute; top:0px; bottom:0px; left:0px; right:0px; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50); } .ic_caption{ position:absolute; opacity:0.6; overflow:hidden; margin:0px; padding:0px; left:0px; right:0px; cursor:default; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=60); } .ic_category{ text-transform:uppercase; font-size:11px; letter-spacing:3px; margin:0px; } .ic_caption h3{ padding:0px 5px 5px 0px; margin:0px; font-size:14px; } .ic_caption h4{ padding:0px 5px 5px 0px; margin:0px; font-size:14px !important; } .ic_text{ padding:0px 5px 5px 0px; margin:0px; text-align:justify; font-size:10px; } .ic_caption a { color: rgb(255,204,0); } .ic_caption a:hover { color: rgb(255,204,0); text-decoration:underline; }
-
Hi. I have some javascript that I need to loop a set number of times. I have used a php query limited to 6. I then need to loop the javascript I have the same amount of times. However it is not looping. It loops through once and stops. Here is the code. //the query $Fetchactivityq = mysql_query("SELECT * FROM Activites WHERE clubid ='".$club['club']."' ORDER BY RAND() LIMIT 6 ") or die('activity error'); // then the images I want to loop further down the page <?php $i = 1; while($row = mysql_fetch_assoc($Fetchactivityq)) { ?> <li id="capslide_img_cont<?php echo $i;?>" class="ic_container"> <?php if ($row['Image']=='activityImage.jpg') { ?> <img src="/images/icons/activityImage.jpg" id="activityImage" /><?php } ?> </li> <?php $i++ } ?> // then at the bottom of the page the problem bit <script type="text/javascript"> $(function() { <?php $i = 1; do { ?> $("#capslide_img_cont<?php echo $i; ?>").capslide({ caption_color : 'white', caption_bgcolor : 'black', overlay_bgcolor : 'black', border : '', showcaption : false }); <?php $i++; } while($row1 = mysql_fetch_array($Fetchactivityq)); ?> }); </script> Thanks for your help Danny
-
no im actual echo rows based on a status number. I just used one for testing. PFMaBiSmAd can you explain why what you said fixed things. Id like to understand. Thanks
-
I have the most simple loop ever on this earth an its doin strange things. There are 6 rows in my cache table. I have a query to echo the rows onto the page with a loop. Now Im try to limit the rows returned to 1 row. simples eh. $FetchCacheq = mysql_query("SELECT * FROM cacheInfo LIMIT 1") or die('cache error'); <table width="480" border="0" cellpadding="0" cellspacing="5"> <tr> <td colspan="2" valign="baseline"><strong>Caches you have found</strong></td> </tr> <?php do { ?> <tr> <td width="250" height="31" align="left" valign="middle"><?php echo $row['cacheName'];?></td> <td width="230" align="left" valign="middle"><img src="/images/submit.png" width="20" height="20" /></td> </tr> <?php } while($row = mysql_fetch_assoc($FetchCacheq));?> </table> The problem I have is its showing two rows. Here is the source code from the page <table width="480" border="0" cellpadding="0" cellspacing="5"> <tr> <td colspan="2" valign="baseline"><strong>Caches you have found</strong></td> </tr> <tr> <td width="250" height="31" align="left" valign="middle"></td> <td width="230" align="left" valign="middle"><img src="/images/submit.png" width="20" height="20" /></td> </tr> <tr> <td width="250" height="31" align="left" valign="middle">Your Life in Their Hands</td> <td width="230" align="left" valign="middle"><img src="/images/submit.png" width="20" height="20" /></td> </tr> </table> as you can see one of the rows doesnt even have the cache name in it!!! please help im really confused.
-
ok so ive found what looks to be a decent image uploader. which if anyone is interested can be found here; http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/ I have followed the instruction and added the few bits needed to make it work properly. However hence me beening here, it doesnt work. Im not overly familiar with the syntax of -> so maybe I am outputting the wrong name in the move_upload_file but the error I get on the server is Unable to move '/tmp/phpJnOkXP' to bla bla bla upload-new.php on line 126 Upload fail which is the move_upload line Here is my code <?php if( isset($_POST['uploadbtn']) ) { $folder = "{$_SERVER['DOCUMENT_ROOT']}/images/test/"; $fileName = $_FILES['newImage']['name']; $tmpName = $_FILES['image']['tmp_name']; include('../simple-image.php'); $image = new SimpleImage(); $image->load($tmpName); $image->resizeToWidth(600); $image->output(); $uploaded = move_uploaded_file($tmpName , $folder.$fileName); if($uploaded){ echo "Upload success"; } else { echo "Upload fail"; } } ?> <form action="" method="post" enctype="multipart/form-data" name="uploadfrm"> <input name="image" type="file" /> <input name="uploadbtn" value="Upload" type="submit" /> </form>
-
thanks again PFMaBiSmAd
-
Ok from one brick wall to the next. After lots of help with my last query I moved onto the next task an I'm completely stuck again. I have a form thats created with a loop. Here is that form <form action="" method="post" id=""> <?php for ($i = 1; $i <= $totalRows_rs_cacheNum; $i++) { echo "<label>Cache ".$i."</label> <span id='sprytextfield".$i."'> <input name='cache[$i]' type='text' value='".$_POST['cache[$i]']."'/> <span class='textfieldRequiredMsg'>Required!</span></span> <div class='clear'></div>"; } ?> <input name="nextbtn" type="submit" value="Next" /> When a user enters data in all the fields, If one piece of information is incorrect an error pops up saying one of the fields you entered does not match the fields in the database. At the same time however i wish to keep the data they have entered in each of the fields. Normally you'd just write value="<?php echo $_POST['fieldName'];?>" but for some reason in this case it does not work. can someone point me in the right direction. I've tried Google many different terms but I can not find the correct term to find my answer. Hence me asking you guys again. Thanks
-
PFMaBiSmAd thank you and thank you to Muddy_Funster you guys rock!! Its sorted and after reading all afternoon I think I could replicate this from now on.
-
ops PFMaBiSmAd I did not see your reply. Let me try thanks
-
ok I have tried to learn what PFMaBiSmAd has suggested I try a couple of hours ago. Here is the new code I have written. if(isset($_POST['nextbtn'])){ foreach($_POST as $key => $value) { $fieldlist[$key] = (trim($value)); unset($fieldlist['nextbtn']); } $qry = "SELECT cacheInfoID, cacheCode FROM cacheInfo WHERE cacheInfoID BETWEEN 1 and $totalRows_rs_cacheNum"; $result = mysql_query($qry) or die (mysql_error()); while($array=mysql_fetch_assoc($result)) { $caches[] = $array['cacheCode']; } $diff = array_diff($fieldlist[], $caches[]); if(!empty($diff)) { $errormessage = "One or all of your entries does not match. Please check your codes and try again"; } else { $url = "success.php"; header("Location: $url"); } } I now recieve this error on the server Cannot use [] for reading on line 59 Which is reffering to; $diff = array_diff($fieldlist[], $caches[]); how can I write this differently? Thanks
-
PFMaBiSmAd Im now way in over my head. I can read the code and I do understand whats going on but loops are not my strong point. You'd have to explain more clearly with dummy data but thanks. When I do a var_dump($dataset) I get this array(6) { [1]=> string( "a7tn39Aj" [2]=> string( "JNr03N6d" [3]=> string( "uQ60M52N" [4]=> string( "qbZpd26M" [5]=> string( "Xq03iNRq" [6]=> string(9) "y510BArqg" } array(6) { [1]=> string( "a7tn39Aj" [2]=> string( "JNr03N6d" [3]=> string( "uQ60M52N" [4]=> string( "qbZpd26M" [5]=> string( "Xq03iNRq" [6]=> string(9) "y510BArqg" } array(6) { [1]=> string( "a7tn39Aj" [2]=> string( "JNr03N6d" [3]=> string( "uQ60M52N" [4]=> string( "qbZpd26M" [5]=> string( "Xq03iNRq" [6]=> string(9) "y510BArqg" } array(6) { [1]=> string( "a7tn39Aj" [2]=> string( "JNr03N6d" [3]=> string( "uQ60M52N" [4]=> string( "qbZpd26M" [5]=> string( "Xq03iNRq" [6]=> string(9) "y510BArqg" } array(6) { [1]=> string( "a7tn39Aj" [2]=> string( "JNr03N6d" [3]=> string( "uQ60M52N" [4]=> string( "qbZpd26M" [5]=> string( "Xq03iNRq" [6]=> string(9) "y510BArqg" } array(6) { [1]=> string( "a7tn39Aj" [2]=> string( "JNr03N6d" [3]=> string( "uQ60M52N" [4]=> string( "qbZpd26M" [5]=> string( "Xq03iNRq" [6]=> string(9) "y510BArqg" }
-
ok so the output of the comparison is below. Just so you know so far i have 6 geocaches so 6 fields needed codes entering in you can see the 6 codes I entered below. a7tn39Aj does not match JNr03N6d does not match uQ60M52N does not match qbZpd26M does not match Xq03iNRq does not match y510BArqg does not match it would seem there is nothing in the {$dataset[$k]}
-
ok that seems to be getting closer. Now I recieve the error "/register-cache.php?error=true" even if I enter the correct values into the fields. Also now Im totally lost with the code. I understand most of it. Just when we move to the dataset bit I get confused. if(isset($_POST['nextbtn'])){ foreach($_POST as $key => $value) { $fieldlist[$key] = (trim($value)); } unset($fieldlist['nextbtn']); $qry = "SELECT cacheInfoID, cacheCode FROM cacheInfo WHERE cacheInfoID BETWEEN 1 and $totalRows_rs_cacheNum"; $result = mysql_query($qry) or die (mysql_error()); while($row = mysql_fetch_assoc($result)){ $keyVal = $row['cacheInfoID']; $dataset[$keyVal] = $row['cacheCode']; } foreach($fieldlist as $k => $v){ if ($v != $dataset[$k]){ $url = "/register-cache.php?error=true"; header("Location: $url"); exit; } else { echo "success continue with working code here"; } } }
-
ok here we go. Ill remove the real escape string. thanks. Yeah sorry Muddy_Funster I had to make a small change to the fields from yesterday. I didnt realise that the admin could add geo locations so I have to make the fields dynamic too. Just to confuse things more <?php include('db.php'); session_start(); mysql_select_db($database_db, $db); $query_rs_cacheNum = "SELECT * FROM cacheInfo"; $rs_cacheNum = mysql_query($query_rs_cacheNum, $db) or die(mysql_error()); $row_rs_cacheNum = mysql_fetch_assoc($rs_cacheNum); $totalRows_rs_cacheNum = mysql_num_rows($rs_cacheNum); if(isset($_POST['nextbtn'])){ foreach($_POST as $key => $value) { $$key = mysql_real_escape_string(trim($value)); } $qry = "SELECT cacheInfoID, cacheCode FROM cacheInfo WHERE cacheInfoID BETWEEN 1 and $totalRows_rs_cacheNum"; $result = mysql_query($qry) or die (mysql_error()); while($row = mysql_fetch_assoc($result)){ $keyVal = $row['cacheInfoID'] -1; $dataset[$keyVal] = $row['cacheCode']; } foreach($key as $k => $v){ if ($v != $dataset[$k]){ $url = "/register-cache.php?error=true"; header("Location: $url"); exit; } else { echo "success continue with working code now"; } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Please enter all cache codes here</title> <link href="main.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="cachewrap"> <div id="head"> <p> </p> <p><img src="/images/logo6.jpg" width="632" height="118" alt="" /></p> </div> <!--<div id="hnav"><?php include('/hnavmain.php'); ?></div>--> <div id="main"> <div id="cachecol"> <h3>Enter all your cache codes here</h3> <p> </p> <p> </p> <p>Please enter all of your codes here. Once complete and your answers have been verfied you can create your account and be entered into our monthly draw.</p> <p> </p> <form action="" method="post" id="allcachecodesfrm"> <?php for ($i = 1; $i <= $totalRows_rs_cacheNum; $i++) { echo "<label>Cache ".$i."</label> <input name='cache".$i."' type='text' /> <div class='clear'></div>"; } ?> <input name="nextbtn" type="submit" value="Next" /> </form> <p> </p> </div> </div> <div id="clear1"></div> <div id="foot">Copyright ©site</div> <div id="subfoot"> <p> </p> </div>
-
ok I now have the following code on my page. 1st the form <form action="" method="post" id="allcachecodesfrm"> <?php for ($i = 1; $i <= $totalRows_rs_cacheNum; $i++) { echo "<label>Cache ".$i."</label> <input name='cache".$i."' type='text' /> <div class='clear'></div>"; } ?> <input name="nextbtn" type="submit" value="Next" /> </form> Once its posted I try to run the values through escape string and trim. Then check they are each the same as in the database. Then if all ok continue with code. but for some reason the page just refreshes. Here is the next part of the code. $qry = "SELECT cacheInfoID, cacheCode FROM cacheInfo WHERE cacheInfoID BETWEEN 1 and $totalRows_rs_cacheNum"; $result = mysql_query($qry) or die (mysql_error()); while($row = mysql_fetch_assoc($result)){ $keyVal = $row['cacheInfoID'] -1; $dataset[$keyVal] = $row['cacheCode']; } foreach($key as $k => $v){ if ($v != $dataset[$k]){ $url = "/register-cache.php?error=true"; header("Location: $url"); exit; } else { echo "success continue with working code here"; } } }
-
thankyou I need to go now but I will try this later on and post as solved.
-
are we still talking php or we moving over to VB with that? All of the values entered need to match perfectly. I forgot to mention that. If thats not the case they ca not proceed.