Jump to content

br0ken

Members
  • Posts

    421
  • Joined

  • Last visited

    Never

Everything posted by br0ken

  1. <?php echo substr($var, $p1, strpos($var, $p2)); ?>
  2. Each time you re-enter your while loop you set $r as 1 and then increment it to 2. This should also number your boxes correctly and display the empty ones. <?php $r = 1; while ($row=mysql_fetch_assoc($countresult)) { echo "<input type='text' class='boxes' name='size_$r' value='"; echo $row['size']; echo "'>"; echo "<input type='text' class='boxes' name='cost_$r' value='"; echo $row['cost']; echo "'>"; $r++ ; } //Now show the empty input boxes for($i = $i;$i <= $count; $i++) { echo "<input type='text' class='boxes' name='size_$i' value=''>"; echo "<input type='text' class='boxes' name='cost_$i' value=''>"; } ?>
  3. I would try writing an echo statement inside the if so that when the $ItemID should be added to the session, a message will be printed informing you this has worked. This way if you see the message then you know it's definately been added and you have a problem with your sessions. <?php elseif (isset($_POST['tocart']) && $_POST['tocart'] == "yes") { if (isset($_POST['buyid']) && $_POST['buyid'] == "selected") { $_SESSION['Cartitems'] = "$ItemID"; echo "Adding $itemID to $_SESSION<br />"; } header("location: cart.php"); exit(); } ?> This will code will cause an error because the header() function cannot be called after you've sent output to the browser but still, just use this for debugging, tell us what happens and then remove.
  4. If the two sites are both based on the same server then by configuring the permissions you can do this however like DarkWater says, if they're on different servers you can't do it. One way around it is on the site with the images, you could add all of their names to a CSV (comma seperated values) file and then grab that using file_get_contents, process it voilla, you have your images!
  5. Does this help? <?php session_start(); // This must be the first thing the page $_SESSION['var1'] = $_GET['var1']; ?>
  6. What is the name of the field in the table that you're trying to extract data from? $search = $data['tblpeople'] - Where you have tblpeople (the table name) you need to have the field name you want to get the data from.
  7. <?php switch (strtolower($_GET['page'])) { case "register": echo "Please click <a href=\"register.php\">here</a> to register your free acount."; break; default: echo "Welcome"; break; } ?>
  8. The error indicates that you (the user running PHP) doesn't have write permissions for the folder you'r trying to write to. You would need to change these permissions and it should run ok.
  9. To pass information through sessions you first have to pass the information in the URL, extract it from $_GET or $_POST and then add it manually to $_SESSION. Are you saying you don't know how to assign information to a session variable?
  10. Try this... <?php if(isset($_POST['Submit'])) { $searchsql = "SELECT * FROM tblpeople"; $searchquery = mysql_query($searchsql); while($data = mysql_fetch_array($searchquery)) { $search = $data['tblpeople'];} if($data['tblpeople'] != $_POST['search']) { echo "works"; } else { "doesn't work";} } } ?>
  11. I'm not sure about CHMOD but mkdir() will take a relative or absolute path as it's parameter.
  12. <?php $var = "a.file.name.jpg"; echo substr($var, strrpos($var, ".")); ?>
  13. <?php $dir = "../../../"; chdir($dir); ?>
  14. I'm not entirely sure what you mean but is this any help? SELECT id, (id-1) AS previous, (id+1) AS next FROM aTable
  15. Try echoing the value in $ext and the file type when iterating through your loop. This way you can see exactly what two values are being compared and whether it's working ok. Try replacing you loop with this... <?php foreach($types as $ext) { echo "ext: $ext<br />"; echo "Type: ".$_FILES["file"]["type"]."<br /><br />"; if($_FILES["file"]["type"] == $ext) { $good=1; } } ?>
  16. What data is actually in $player? If you could show us that it might help. Also, try running stripslashes() on $player before passing it to str_replace(). It's a long shot but it might just work!
  17. The difference between a DO and a WHILE is that a WHILE loop checks the statement passed to it before entering the loop where as a DO will process the loop once and then check the statement. Both of your codes work but Barands code checks whether results have been returned before processing the loop.
  18. <?php $var = 5; echo number_format($var, 2, ".", ""); ?>
  19. This method is only as insecure as using just session_start() because sessions by default use a cookie to store the session id. It is true however that if a malicious user got hold of your session id, they could steal session. I recommend using session_regenerate_id() when the user logs in/out or has any change in authorisation level. Infact, use it as often as possible. This function creates a new session id so if a hacker did get hold of your id it would be useless pretty much instantly. There are some good tutorials on the internet about session security in PHP so I would suggest given them a read for a more indepth discussion about this.
  20. Use this function to validate email addresses instead! <? function validEmail($email) { if (filter_var($email, FILTER_VALIDATE_EMAIL)) return true; else return false; } ?>
  21. <?php error_reporting(E_ALL ^ E_NOTICE); ?> Put this at the top of your page to turn off notice errors.
  22. <?php session_id($sessionID); session_start(); ?>
  23. <?php $path = "includes/sites/centre/test/"; // Directory containing files $newFile = "includes/sites/centre/test/saturn.php"; // Path to new file $fType = strtolower(substr($newFile, strpos($newFile, "."))); // File type of files to collate (got automatically) $file = @scandir($path); if ($file) { echo "Copying all $fType files from '<b>$path</b>' to '<b>$newFile</b>'<br /><br />"; foreach($file as $file) { if (strlen($file) < 3) continue; if (strtolower(substr($file, strpos($file, "."))) != $fType) continue; if (strtolower($path.$file) == strtolower($newFile)) continue; $f = fopen($path.$file, "r"); if ($f) { $buff = fread($f, filesize($path.$file)); $f = fclose($f); $f = fopen($newFile, "a"); if ($f) { fwrite($f, $buff); $f = fclose($f); } } } } ?>
  24. Doesn't just using session_start() do this? If not you could set a cookie storing the session id, grab that value and start a session based on that value however this seems superflous as this is the usual way sessions should work anyway! I guess it's a worth a try though if nothing else will work.
  25. I assumed he'd stored a timestamp in the database and that's what he was retrieving...
×
×
  • 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.