Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by ginerjm

  1. Not sure what is supposed to happen so I did a bit of reorganization of your code to help understand it better. $store_path = './'; // save to folder above current $name = date('ydhis'); // use a name of yyddhhmmss if(!is_dir($store_path . $name)) { mkdir($store_path.$name); // make a new dir above current using current time echo "Dir $store_path$name has been created<br>"; } else echo "Dir $store_path$name already exists<br>"; // dir already exists. How? $filename = $store_path . 'starttoken.php'; if (copy('tokenmaster/starttoken.php', $filename)) echo "Copy to $filename was successful<br>"; else { echo "Copy to $filename failed<br>"; exit(); } $date = new DateTime(); $newname = "./tokendone" . $date->format('ydhis') . ".php"; if(rename($filename, $newname)) echo "Rename of $filename to $newname was successful<br>"; else echo "Rename of $filename failed<br>"; $savename = $store_path.$name.'/'.$filename; echo "Attempting to save some data to $savename<br>"; if(file_put_contents($savename, $yourcontent) === false) echo "Save to $savename failed<br>"; else echo "Save to $savename succeeded<br>"; exit(); Run this and see what messages you get.
  2. By the time I cleaned up the code I seem to have forgotten how it began and lost focus on what was being shown. Yes - a horribly mis-arranged block of code that Mac_gyver has seen more clearly than I. Kudos to him! #abadon - may I ask what your second post is all about? Looks like a screenshot of a PHPadmin table browse window which has nothing to do with the question.
  3. Maybe a td tag inside the inner foreach loop instead of a tr tag?
  4. Your cleaned up code, such as it is: <label>Title</label <input class="form-control" type="text" name="title"; <label>Аuthor</label> <input class="form-control" type="text" name="author"> <br> <div style="padding-left: 10px;"> <button type="submit" name="save">save</button> </div> <?php include 'config.php'; if(isset($_POST['save'])) { if($link->connect_error) { die('Connect failed: '.$link->connect_error); } else { $stmt = $link->prepare("insert into user_books(user_name_books, user_name_author, user_year, user_ISBAN) value(?, ?, ?, ?)"); $stmt->bind_param("ssss", $title, $author, $year, $isban); $execval = $stmt->execute(); if(!isset($title) || trim($title) == '') { echo 'You did not fill out the required fields title'; } else { if(!isset($author) || trim($author) == '') { echo " You did not fill out the required fields author"; } else { if(!isset($year) || trim($year) == '') { echo 'You did not fill out the required fields year'; } else { if(!isset($isban) || trim($isban)=='') { echo 'You did not fill out the required fields isban'; } else { header("Location: homeUserFinish.php"); } } You are showing us how you are handling the received POST data. The only thing is where do all of the fields you are editing come from since you don't show us? It seems that if you don't have any POST data you don't do any of these checks so that is one hole. And since you are asking about the 'save' process, it would be helpful if you showed us THAT code from your other script instead of this one.
  5. Well - I knew I didn't understand but from the writings I thought this was a sharing of individual sessions and that was what I was discussing. Still not sure what it is you are doing but you are making it sound less dangerous.
  6. I'm glad (and surprised) that someone understands what the OP is attempting (succeeding?) to do here. Makes no sense at all to me and surprises me that one can manage to tap into someone else's session values despite PHP's design to hopefully not allow that. Why not use a db with a well-identified record key so that the data in it can be safely/properly shared without all of the concern for breaking PHP's built in security scheme? Just sharing the db between domains is a surprise in itself but I guess if the user has setup his domains to point to the same db server that problem is non-existent.
  7. Since the manual says you can use a string as the pattern you certainly could use a file to provide that string. Easy-peasy. But - you want to do a 'search' for hundreds of items? That could take some time don't you think? Are you sure you really need to do this thing?
  8. Run your query (I used pdo) and then do the following: $row_size = 3; $cnt = 0; echo "<table><tr>"; while($row = $pdo->fetch()) { if ($cnt == $row_size) { echo "</tr><tr>"; $cnt = 0; } echo "<td>{$row['item']}</td>"; $cnt++; } echo "</tr></table>";
  9. What do you think that explode is doing for you? Did you echo out your user and uid values after the explode Here is what I get: $data = "foo:home,food,brand:tulasi"; list($user, $uid) = explode(":", $data); echo "user is $user and uid is $uid"; exit();
  10. FYI - the code above is missing a couple of semicolons Note how the code was written without leaving PHP mode and thus avoids the messy way of having to code your p tag so clumsily. AND - if this is not the sole contents of your php script then leave out the ?> tag. It is not required nor is it needed to end a script. Entering and leaving php mode is not a practical way of coding a php script. Sure - you may have some block of JS code so you can do it but when all you are doing is running php logic and then assembling php results with html code use the echo and double quotes and avoid the in-and-out style of coding php results. Just my $.02
  11. I think you misunderstood my question. What makes you think that they are hitting your site at all? Some of your logs maintained by your domain? Do you have a few domain names of these sites that are in your logs that are clearly xxx sites?
  12. So you are telling us that you can see in some log of your site's activity that porn sites are trying to see your pages? That does seem odd... It is usually the other way around.
  13. Here's is how you could handle the problems that people are mentioning. Just a quick "how I would do it": $errmsg = ''; if ($_GET['id'] == '') $errmsg .= 'Missing id value<br>'; else { $q = "SELECT * FROM peminjaman WHERE id_peminjaman='" . $_GET['id'] . "'"; if (!$get = mysqli_query($con, $q)) $errmsg .= "Query failed to run<br>Query was:<br>$q<br>"; } if ($errmsg <> '') { // show the errmsg and let the user know he has // a problem and stop this script } // continue on with query results $fetch = mysqli_fetch_array($get); $nama_pegawai = $fetch['nama_pegawai']; $tanggal_pinjam = $fetch['tanggal_pinjam']; $tanggal_kembali = $fetch['tanggal_kembali']; // no need to do the above 'assignments' when you can simply // use the values from the fetched array You really should check the results of your query since any error in your statement or possibly with your db server will cause issues.
  14. Actually I should have said - "create the SAME single entry in an array". Which kind of makes it a needless function.
  15. Can I ask - why do you need this function? All it does is create a single entry in an array and never anything else. What's the point? You could simply place this code in your mainline code and not have to create a function.
  16. It's an .html file is the problem
  17. I find it funny when I see people using sprintf/printf to display something that a simple echo accomplishes. I NEVER use those 2 functions. Don't understand.
  18. $root is the path to your domain's root. As in: $root = $_SERVER['DOCUMENT_ROOT'] . "/"; Sorry - didn't see that was in there. And don't "put tags around" the code. All one ever needs is the <?php tag. As already mentioned the ?> tag is not needed. And don't forget to add the lines that enable error checking to this as I noted.
  19. Don't you want to use two dots to reference the styles folder if you are already down in the includes folder? Personally I store my 'project' stuff in a specific folder for that project and don't have to worry about all that. If I really needed to separate project-specific files into their own sub folders then that is exactly what I would have - sub-folders under the project-specific folder rather than folders in a parallel structure. And if I have certain files that are global to much of my work (such as a db connection file) those I store in an upper level folder (outside of the web-accessible tree) where all my projects can reference them with a root-level path conjoined to that folder.
  20. I use a little stub of a script to debug those errors that prevent a script from running. if (isset($_GET['call'])) { // test the script named as the 'call' arg in the url $call = $_GET['call']; require $root . $call; } else { echo "Must supply a call= argument for the script to be tested"; echo "root is $root<br>"; } //******************************** exit(); Be sure to add the error setting lines at the top of this and then save it. I call mine 'redirect.php' and add a ?call=scriptname in the command line when I use it. Note that it won't run if you already have get parms in your problem script so simply provide only the script name.
  21. Did a quick (Really quick!) lookup and found this. You have the wrong syntax so apparently you did not do your homework. INSERT INTO destination_table_name(column_1, column_2) SELECT column_1,column_2 FROM source_table WHERE condition;
  22. Try this to see if there are some issues: $q = "INSERT INTO a SELECT * FROM b WHERE id='" . $_POST["id"] . "'"; if (mysqli_query($conn, $q)) echo "Insert query successful"; else { echo "Insert query failed. Query is<br>$q<br>"; exit(); } $q = "DELETE FROM b WHERE id='" . $_POST["id"] . "'"; if (mysqli_query($conn, $q)) echo "Delete query successful"; else { echo "Delete query failed. Query is<br>$q<br>"; exit(); } echo json_encode(true); // Not sure what this is. If you get a failure try adding the mysqli error reporting function to it as already suggested. This will give you at least some indication. Suggestion - IMHO it is good practice to NOT bury a query statement inside of another function as you are doing. By assigning it to a variable it makes it easy to echo out your query string should you want to analyze it during any debugging you may need to do as in this case perhaps.
  • 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.