Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. On this line (and another below): echo '</td>' . foreach ($history as $key) { echo "$key <br />"; } You're trying to concatenate a string with a piece of code, you can't do that. These are separate statements, so need a semi-colon between them: echo '</td>'; foreach ($history as $key) { echo "$key <br />"; }
  2. No, that wouldn't send whitespace to the browser because it would be interpreted(or, more accurately, ignored) by the PHP engine. You get whitespace in any HTML that you might send to the browser. One of the important things to recognise is that anything not contained within PHP tags is considered HTML. So the following code fragment would send a line of whitespace: <?php //code ?> <?php //more code ?> As would the following code (which is often the cause of the header error): <?php //code ?> It's more difficult to spot, since it's at the top of the code. Further, in included files, you shouldn't have any whitespace after the closing PHP tag, as this could cause you troubles.. Indeed, it's valid (and recommended by some coding standards) to leave off the last closing PHP tag of a file if there's no HTML to follow to avoid this problem.
  3. Yes. You can use cURL for starters. However, isn't there a paypal API for all this?
  4. Or indeed anyone by hand, the firebug extension for firefox and bots to name but a few. You must be doing something wrong if the user has an opportunity to change the price.
  5. Or, more specifically, a notice. Which a lot of people don't realize exists, owing to their error reporting level. In any case, the second call is ignored.
  6. Well I assume you should move this line: $pdftext = pdf2txt('C:\Users\Mike\Desktop\Athy Database\Athy Register.pdf'); To outside of all the functions. Not having written or looked at the code, I can't guarantee that will work for you, however.
  7. If you're annoyed by that, i wouldn't stick around. We get much worse Don't forget that English might not be everyone's first language. That said, you do have a point....nirVaan, you should really try to make more effort to punctuate your posts.
  8. Yes. You're calling the function (pdf2txt()) from within itself, with no condition for breaking out. So the function is being recursively called indefinitely.
  9. The first thing i notice which could be wrong is that you're not providing a cookie jar. The request to the login will, no doubt, set a cookie. However, you're following location and the home page will no doubt check the existence of said cookie. It wont be there, so it'll redirect you to the login page. There could be other things wrong, however. Have you checked carefully about what data is POSTed to the login page? The firefox Live HTTP Headers extension is pretty useful for this...
  10. No, that header is sent on a separate request to the webserver. Headers (amongst other things) tell the browser what kind of data is being sent. When you load the page with the form on, your browser makes a request to the webserver, which serves the webpage. You may or may not have sent a header with this response and, if you haven't, the browser will guess that it's supposed to be HTML. One of the things the page contains is an image. The browser must then fetch that image also, which is a separate request. A different request may, of course, be for different content. Whitespace in your PHP/HTML code are output to the browser, although they don't "do" anything. That is why you'll not see them unless you view the source of the webpage in your browser or output the php code to a file/stream.
  11. I don't know. You still haven't really told us what the problem is. Why don't you take a little more care over your posts and explain things more fully? As before, I can continue to stab in the dark...my next guess (without any more information) is that your query is failing and you have the display of errors turned off. Add the following two lines to the top of your script: error_reporting(E_ALL); ini_set('display_errors','On'); And add some debugging to your query. Replace this line: $query = mysql_query("SELECT * FROM members WHERE picture='$picture'"); With: $query = mysql_query("SELECT * FROM members WHERE picture='$picture'") or trigger_error(mysql_error(),E_USER_ERROR);
  12. Well the syntax error is due to the lack of braces around your if/else statements. Try: <?php session_start(); if ($_SESSION['username']){ echo "Welcome, ".$_SESSION['username']."!<br><a href='Logout.php'>Log Out</a>"; $stacks = array(" <form enctype='multipart/form-data' action='insert.php' method='post' name='changer'> <p align='center'><input name='image' value='image' type='text'> <br> <input type='text' name='hyperlink'value='hyperlink'> <br> <input type='text' name='currency' value='currency'> <br> <input type='text' name='name' value='name'> <br> <input type='text' name='info' value='info'> <br> <input type='text' name='keywords' value='keywords'> <br> <input type='text' name='type' value='type'> <br> <input type='submit' value='Submit'><br></p> "); }else{ die("You must be logged in!"); } ?> <?php <form enctype='multipart/form-data' action='Admin.php' method='post' name='changer'> <input type='submit' value='duplicate'> $button = $_GET['duplicate']; if(!$button) array_push($stack, $stack); echo $stack; Though i'm afraid things aren't quite as simple as you've got there. You'll need to name all your input fields as arrays. Each time the "duplicate" button is clicked, you'll have to loop through each field and echo out the value if it exists -- otherwise you'll get your new input fields, but you'll lose all the data. Here's an old script where i did something similar: <?php $userid = $_SESSION['uid']; $done = FALSE; if(isset($_POST['makepayments'])){ $inserts = array(); foreach($_POST['category'] as $x=> $category){ if(!empty($_POST['amount'][$x]) && $_POST['amount'][$x] > 0){ $amount = mysql_real_escape_string($_POST['amount'][$x]); $date = mysql_real_escape_string($_POST['date'][$x]); $details = mysql_real_escape_string($_POST['details'][$x]); $inserts[] = "('".mysql_real_escape_string($category)."','$details','$amount','$date',$userid)"; } } $insert = implode(',',$inserts); if(count($inserts) > 0){ $sql = "INSERT INTO items (cat_id,description,price,purchase_date,uid) VALUES $insert"; mysql_query($sql) or trigger_error(mysql_error().'<br />Query Was: <br />'.$sql,E_USER_ERROR); } $done = TRUE; $doneamount = count($inserts); $_POST = array(); } ?> <h3>Make Payment</h3> <?php if($done===TRUE){ echo $doneamount. ' payment(s) successfully added<br /><br />'."\n"; } $sql = "SELECT COUNT(*) FROM categories WHERE uid=$userid"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); if(mysql_result($result,0)==0){ echo 'Before you can add a payment, you need to add some categories. Go to <a href="index.php?page=admin">the administration page</a> to add some.'; }else{ ?> <form method="post"> Reload with <select name="numfields" /> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="10">10</option> </select> field(s) <input type="submit" name="reload" value="Reload" /> <br /> <br /> <table> <tr> <th>Details</th> <th>Spent On</th> <th>Date</th> <th>Amount</th> </tr> <?php if(isset($_POST['reload'])){ $numfields = (int) $_POST['numfields']; }else{ $numfields = 1; } for($x=0;$x<$numfields;$x++){ echo "<tr>\n"; echo '<td><input type="text" name="details['.$x.']" value="'; echo (isset($_POST['details'][$x])) ? $_POST['details'][$x] : ''; echo '" /></td>'."\n"; echo '<td>'."\n"; echo '<select name="category['.$x.']">'."\n"; $sql = "SELECT id,name FROM categories WHERE uid=$userid ORDER BY id ASC"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); while(list($id,$name) = mysql_fetch_row($result)){ $selected = ''; if(isset($_POST['category'][$x]) && $_POST['category'][$x] == $id){ $selected = 'selected="selected"'; } echo '<option value="'.$id.'" '.$selected.'>'.$name.'</option>'; } echo '</select>'; echo '</td>'."\n"; echo '<td>'."\n"; echo '<input type="text" name="date['.$x.']" value="'; echo (isset($_POST['date'][$x])) ? $_POST['date'][$x] : date('Y-m-d'); echo '" />'."\n"; echo '</td>'."\n"; echo '<td><input type="text" name="amount['.$x.']" value="'; echo (isset($_POST['amount'][$x])) ? $_POST['amount'][$x] : ''; echo '" /></td>'."\n"; echo '</tr>'; } ?> </table> <br /> <input type="submit" name="makepayments" value="Make Payments" /> </form> <?php } ?> Lastly, you could have this work a lot nicer with Javascript -- the page wouldn't have to reload each time you add fields. It's pretty easy to accomplish with the jQuery framework too.
  13. The only thing i can see obviously wrong with your code is that you've not placed a call to session_start at the top of your code. Beyond that, you'll actually have to tell us what's wrong, what you want to happen, what isn't happening, what is happening etc.
  14. By blank you mean a completely blank page? Do you have any other output that's supposed to be displayed? If so, chances are you have an error and have display errors turned off. Otherwise, is the while loop even running? Perhaps there are no rows in the result set.
  15. Just because a field is hidden, you cannot rely on it. A malicious user could still tamper with the data. You need to validate hidden fields also
  16. Well without knowing what it is returned by the fetchrow() method, it's a little difficult to help. I'd start by passing $gang to var_dump and see what it contains.
  17. Sure, just add another condition to your WHERE clause: SELECT * FROM yourtable WHERE colors=(SELECT colors FROM yourtable WHERE id=$id) AND id != $id
  18. Apologies, yes. I'm not really sure where incoming came from. I guess i must have been doing two things at once
  19. Yeah, it probably is: <?php $mytext = "<h1>Title One</h1><br>This is text one<br><br><br><h1>Title Two</h1><br>This is text two<br><br><h1>Title Three</h1><br>This is text three"; preg_match_all('|<h1>(.*?)</h1>|s',$mytext,$matches); foreach($matches[1] as $key => $title){ echo "<a href=somepage.php?id=" . ($key+1) . ">" . $title . "</a><br>\n"; } ?>
  20. Well if the break line tags always come at the end but are variable in number, you could modify my code by using preg_split instead of explode(): $mytext = "<h1>Title One</h1><br>This is text one<br><br><br><h1>Title Two</h1><br>This is text two<br><br><h1>Title Three</h1><br>This is text three"; $titles = preg_split("|(<br>)+|i",$mytext); for($x=0;$x<count($titles);$x+=2){ echo "<a href=somepage.php?id=" . (($x/2)+1) . ">" . strip_tags($titles[$x]) . "</a><br>\n"; } But it may be that regular expression solution would be neater.
  21. Did you try the code i supplied? Unless i miss-interpreted your original description, i think it fits the bill
  22. They also failed to realise that, regardless of the DRM used, there would be a constant cat-and-mouse game of people finding ways around it. So once again, it's the people who wouldn't try and share music who suffer while those that do share music don't.
  23. I've always used last.fm more as a record of the music i've listened to (can be surprising to see what you listen to most!) and as a way of getting recommendations, rather than for actually playing music. I know they have their radio stations and such, but i've never really found it that great to use.
  24. I don't think spotify has been launched yet in the US, but this kind of thing might really work. It's a streaming music service supported by adverts. You can play as much as you like and get an advert around every 8-10 songs, and i think they aim to tie them in with the end of an album if possible. Less adverts than a radio station and you get to choose the music. Or you can pay to have the adverts removed and it becomes more like your regular subscriptions service. It's certainly enjoying a lot of usage here in the UK. And i'm not surprised really...it's less effort to stream something and start listening instantly than it is to download, the library is pretty large and the adverts really aren't all that intrusive. I'd imagine there's pretty decent potential for advert revenues too. Targeted advertising is always a better and i'd imagine you could get a fairly accurate idea of a listener's demographic from the music listening history.
  25. I would imagine it would be easier to go with my first method if you intend to display text as well. But to answer the question, yes you could write text to the image and have the barcode displayed below.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.