-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Adam
-
During your loop: if (array_key_exists($row['ingredient'], $ingredients)) { // not sure if you wanted to add (+) the quantity value here... $ingredients[$row['ingredient']] += $row['quantity']; // or just increment the value.. // $ingredients[$row['ingredient']]++; } else { // same here, if adding.. $ingredients[$row['ingredient']] = $row['quantity']; // if incrementing.. // $ingredients[$row['ingredient']] = 1; } Hopefully that made sense?
-
I have 2 solutions in mind, but the one to use would depend on the limit of this query. Will it just always be 4 rows/stories returned, or should be [able to cope with] unlimited?
-
Try: /Seat ([0-9]+): (.*?) \(([0-9,]+)\)/
-
It's a reserved word in MySQL: http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html
-
A PHP review system of what?
-
So you want to place them in a grid like..? 1 3 2 4 That's a little more difficult to do as you're not counting through them in a logical way. 1 2 3 4 ... would be easier as on the second 'story', you could just start a new table row within your loop. I've got to shoot for a couple of hours but if you don't have a solution to achieve that later I'll come back.
-
Which variable?
-
I have to shoot in a moment, so don't have enough time to look into this properly. Try replacing the include file with "upload.php" and see what happens. Good luck!
-
What's in "upload.php"? Sounds to me like you should be including that file..
-
Your comment says "Load form template" above the include; the code you've posted doesn't look like a form template to me. Where is the HTML for the form stored? That's probably the file you need to include.
-
In file-upload.php you have: function showUploadForm($message='') { $max_file_size_tag = ''; if (MAX_FILE_SIZE > 0) { // convert to bytes $max_file_size_tag = "<input name='MAX_FILE_SIZE' value='".(MAX_FILE_SIZE*1024)."' type='hidden' >\n"; } // Load form template include ('file-upload.php'); } Notice the include at the end, you're including the same file again - which means you're going to declare the function again. There's your problem. NB It's easier to read/copy the code if you place it within tags..
-
"every file in the FTP"? Can't fully understand what you're asking here.
-
Being as the form just submits back to the same page, if you pass the correct data the application should handle it as you expect. You don't ever tell cURL to "submit a form", you just send a request to the specified URL - or by that did you mean pass the submit button's name as data as well? Whatever the case, you need to work out what data is required for the application to process the form. The JavaScript calls the .submit() method, so it's something relating to the actual inputs; have you spotted the hidden inputs at the top of the form? I guess it's also possible they're also using some server side technique to prevent you making such a request.
-
No worries.. $ad = 0; while ($row = mysql_fetch_assoc ($result)) { if ($ad == 4) { //display advert $ad = 0; } $date = $row['postdate']; $date = date("D dS M", strtotime($date) ); $title = stripslashes ($row['title']); $image = stripslashes (strip_tags($row['image1'])); echo "<div class='entry'> <div class='image'><img src='images/news/$image' width='108' height='78'></div> <div><a href='article.php?id=$row[id]'>$title</a></div> </div>"; $ad++; }
-
That was just a rough example, it can be adapted easily. How exactly are you looping?
-
What do you mean decode it?
-
Unfortunately that type of approach won't work. Have you tried running a simple example? Depending on the way you implement it, the first advert would appear in-place on the first run, but after that the order would become messed up. The only way for it to remain after every 4 using that method would be to display the advert and continue (skip) to the next iteration; which obviously you don't want to do. If you displayed both the advert and the current iteration, you'd be inserting an extra row and so the advert would appear after the 4th on the first appearance, but every 5th after that. --- What you need to do is increment a counter, and as it reaches 4 reset it. Rough example to demonstrate what I mean: $ad = 0; for ($i = 1; $i <= 20; $i++) { if ($ad == 4) { echo 'advertisement<br />'; $ad = 0; } echo $i . '<br />'; $ad++; } Not tested that code.
-
He's already fixed it? There was, now there's 2. There was nothing wrong with the concatenation.
-
Sorry, didn't look too much into your code after your comment: Your IF block is totally redundant. Why store $item as 1 or 2, when you know $_GET['add'] is equal to that already? Where is $session coming from? $item doesn't get stored at all in your code. -- I think you need to plan this out a little more. Where do these product IDs (1 & 2) come from?
-
Why not just store them as an array?
-
Why echo out all of the image tag? <iframe src="<?php echo $e . $f; ?>" width="400" height="250" frameborder="0" scrolling="no"></iframe>
-
Where are you expecting to get the URL from?
-
I can't see $getuserq anywhere in your original code (possible I'm overlooking it). Reason I was asking is, as DevilsAdvocate pointed out, all you have are the statements. I was assuming $getuserq was going to hold the result resource for $getuser, but obviously it's just another query.
-
redirect the page to same location after login
Adam replied to shahzad429's topic in PHP Coding Help
You'll need to pass a return URL. For example, in your HTML populate a hidden input with the current URI: <input type="hidden" name="redirect" value="<?php echo urlencode($_SERVER['REQUEST_URI']); ?>" /> Ensure you use urlencode to prevent the query string causing problems. Then within the PHP: // all your logic here if (!empty($_POST['redirect'])) { header("Location: " . urldecode($_POST['redirect'])); } You may want to add in some extra security to prevent people inserting their own little URLs, but that's the basics behind it.