Jump to content

ash992

Members
  • Posts

    56
  • Joined

  • Last visited

Everything posted by ash992

  1. oh btw, I've just taken a look in the database and this is what is imported when I run the script so possibly the reason for it saying there's a duplicate is becuase I'm uploading the array incorrectly? so it's just trying to upload the wrong values everytime to the same row? :S if you know anything about this it would be great, thanks again in advance!
  2. hey guys, I'm getting a problem uploading my csv file to mysql database, the code on the top half just makes sure that I don't import data that I don't want into the database, numbers that are too high or too low on certain rows, and the second half is importing the array that I create from the csv file into the database however I'm getting the following error Now I've never had this error before and I'm not sure what's causing it so any help would be very much appreciated $data = array(); if (($handle = fopen("stock.csv", "r")) !== FALSE) { while (($row = fgetcsv($handle, 1000, ",")) !== FALSE) { // only add rows to the array where the 4th column value is greater than or equal to 10 if(($row[3] >= 10 && $row[4] >= 5) OR ($row[3] >= 0 AND $row[4] > 5)){ if($row[4] < 1000){ $data[] = $row; } } } foreach ($data as &$value) { mysql_query("INSERT INTO tblProductData (intProductDataId, strProductCode, strProductName, strProductDesc, strProductStock, strProductCost, dtmDiscontinued, dtmAdded, stmTimestamp) VALUES(null, '$data[0]', '$data[1]', '$data[2]', '$data[3]', '$data[4]', 'time', 'added', 'time') ") or die(mysql_error()); } } Thanks in advance guys! if you have any clue at all I'd love to hear it.
  3. Thank-you very much for your time and help Ch0cu3r! hope you have a great day
  4. Hmm there's a few different problems, I'm creating my array from a csv file, after the third comma on every line it has a number that I want to check if it's less than 10, $data = fgetcsv($handle, 12000, "," (this is where I create the variable that reads the csv file) is it possible to pick a specific row in the key to check? or should I try to find a different method of doing this? Thank-you very much for the help and quick response! much appreciated
  5. Hey guys so I've been trying to figure something out for a day now but I really don't know where to start, basically I'm trying to create some kind of function that goes through my array and checks if the keys value is less than 5, if it is then I want to unset the key removing it from the array, I programmed this underneath as this is basically what I want to achieve however there's a syntax issue as the array_key_excists function doesn't seem to allow the if statement, if anyone knows anything about it it would be very helpful! if (array_key_exists(($key > 5),$data)) { unset($data[$key]); } any help is very much appreciated, Thanks very much in advance!
  6. YES. thank-you so much! the password field was 1 character too short to hold the full thing! been working this for well over 2 days xD always a simple issue.. Thanks a lot!
  7. Sorry for the slow reply there, yeah they're exactly the same for sure, I even tried copying the table names from the database to double check, they're definitely exactly the same :\
  8. yeah that currently equals 0, that's kinda where this is going wrong :\
  9. }else { echo $email; echo $pass; echo md5($pass); echo 'it didn\'t work'; echo mysql_error(); //Login failed //$_SESSION['errorsec'] = "Invalid email address or password"; //header('Location: ../Checkout'); //die(); } weirdly all of these are outputting the correct thing, still the only thing that's not working is the mysql_num_rows($result) is equal to 0 instead of 1, that would usually mean that it can't find the correct username and password in the customers database, however I have the mysql database opened and they're both there and correspond exactly with the inputs.. :s
  10. ah sorry! I've changed it to echo mysql_error(); however there is still no output when I enter the correct details other than
  11. }else { echo 'it didn\'t work'; mysql_error(); die(); //Login failed //$_SESSION['errorsec'] = "Invalid email address or password"; //header('Location: ../Checkout'); //die(); } there is no output when I changed it to that :\ not really sure if I was echoing the mysql error correctly as I've never used it, I'm just seeing if there's an alternative to the mysql_num_rows($result) as I believe that's the issue though I haven't found anything yet
  12. yeah it is stored with md5 but it's also checked with md5 so it should be fine, I'll try looking at the myqli and pdo stuff you mentioned though Thanks, Also thanks for showing me the mysql_real_escape_string(); I'd never even heard of it
  13. yeah I added the curly bracket, I just mis-copied the code erm well the error I'm getting is the output of //Login failed $_SESSION['errorsec'] = "Invalid email address or password"; header('Location: ../Checkout'); die(); however if I put something to test the conditional statments' success like by just echoing something there, then the if($result) { is passed fine when the login details are correct, however the if(mysql_num_rows($result) == 1) { doesn't work as mysql_num_rows($result) currently equals 0, even though the correct email and password are in the mysql database :s
  14. Hi everyone, so I programmed this login script a long time ago for a website I had, I'm now trying to reuse it and I can't get it to work, I've tried replacing everything, and testing things, I've found one problem but as far as I know the problem shouldn't be happening, here's the code. <?php include 'connect.php'; session_start(); $email = ($_POST['email']); $pass = ($_POST['password']); //check missing data if($email == ''){ $_SESSION['errorsec'] = "Please enter an email address!"; header('Location: ../Checkout'); die(); } if($pass == ''){ $_SESSION['errorsec'] = "Please enter a password!"; header('Location: ../Checkout'); die(); } //Create query $qry="SELECT * FROM Customers WHERE Email='$email' AND Password='".md5($_POST['password'])."'"; $result=mysql_query($qry); //Check whether the query was successful or not if($result) { if(mysql_num_rows($result) == 1) { //Login Successful echo 'temp'; die(); }else{ //Login failed $_SESSION['errorsec'] = "Invalid email address or password"; header('Location: ../Checkout'); die(); }else { die("Query failed"); } ?> First of all I know that the email and password are being taken from the forms correctly as I've tried echo'ing them both, however the Issue that I've found is that even when the password and username are entered correctly, mysql_num_rows($result) is still equal to 0, now I'm pretty bad with mysql hence reusing a script from a long time ago but I have no idea of what's going wrong really, Any help would be much' appreciated! Thanks alot in advance.
  15. Thanks for the replies guys very useful, and I understand that by people reaching the review page doesn't mean they're ordered, but I've just set it to store their order and details including what they've ordered, quantity, price, address etc in a database that also stores their email, so if I get that entry into my database followed by a paypal payment then I know to send them a package because I've received the money and I'd never actually heard of the PDT thing from paypal before but this is exactly what I was looking for thank-you both very much for your help Have a nice day
  16. basically I'm trying to setup a shop in php, so on a previous page you have to enter all of your details about your address, this page just shows you all of those details before you pay, the form is a payment button created by paypal. it's important to destroy the variables as if someone visits the website after making a purchase I don't want things like the basket to still say that it has items inside of it, however if someone is to refresh the page for whatever reason before they press pay now on the page that shows their detials they'll loose all of the information they have entered, and the items they had inside of their basket. hope that helped, thanks very much for the fast reply
  17. Hi guys, I'm just trying to create a page in which I want to destroy all of the session variables upon leaving the page (Via a form being submitted), however if someone hits the refresh button I don't want the sessions to be destroyed. I unfortunately can't just destroy the sessions upon getting to the form action location as that's not on my site. So I understand that session_destroy(); will destroy them all when I leave the page, however this will also destroy them when I refresh the page, does anyone know if this is even possible to do with php? because I really don't have a clue where to go here... Thanks very much in advance, any help is much' appreciated!
  18. Goddd. Thank-you very much! it's working now, can't believe I didn't see this. thanks a lot though )
  19. Hi guys, so I've been getting this syntax error for the past 2 days, and I can't get it to work at all... though I'm sure it's probably something quite simple that I just haven't noticed. the error is in the document there is the following code; <?php session_start(); $name = $_SESSION['name']; $rows = $_SESSION['rows']; $price = $_SESSION['price']; $choice = $_SESSION['choice']; $quan = $_SESSION['quantity']; $remove1 = $_POST['remove1']; //CHECK FOR ITEMS TO BE REMOVED if ($remove1 == 'yes'){ $rows = $rows - 1; $_SESSION['rows'] = $rows; unset($_SESSION['name']); unset($_SESSION['price']); unset($_SESSION['choice']); unset($_SESSION['quantity']); unset($_SESSION)['AVA']); } Line 14 is empty, but the line follows is the line that reads $remove1 = $_POST['remove1]; I can't see a syntax error, but possibly I've missed something simple. any advice would be much appreciated! thank-you in advance
  20. Oh.. I slightly changed the syntax of the log-in file and now it works? I had a broken if command, but instead of giving me an error it gave me 403. xD Thanks guys.
  21. Okay this is very weird... If I open the directory in my browser, and press on the file, It loads successfully, however if my browser re-directs from the page where the user enters his log-in detials, the 403 occurs? I've also tried changing the directory of the file to the root, and made sure the premissions were fine, both didn't help, here's the page where you type your details but it looks fine to me... :s <form action="login.php" method="POST"> <input type="text" value="username" name="user"/><br /> <input type="password" value="password" name="password"/><br /> <input type="submit" value="enter" /> </form> Oh and both; when you press on the link from the directory's URL and when you go from the log-in page's URL, are exactly the same, so it's not a case of a misplaced slash or something:s
  22. Hey everyone, So I just set up register and log-in scripts on my site, I've used this script a few times before and it's usually fine but for some reason every time I try to log in the log in page comes up with a 403 error, (Forbidden), Here's the code for the page : <?PHP session_start(); $user = $_POST['user']; $pass = $_POST['password']; $con = mysql_connect("localhost","xxxx","xxxx") or ("Cannot connect!" . mysql_error()); if (!$con) die("Could not connect: " . mysql_error()); mysql_select_db("xxxx" , $con) or die ("could not load the database" . mysql_error()); $check = mysql_query("SELECT * FROM example WHERE `user`='".$user."'"); $numrows = mysql_num_rows($check); if ($numrows == 0) { die ("User does not exist \n"); } else { $pass = md5($pass); while($row = mysql_fetch_assoc($check)) { if ($pass == $row['pass']) $_SESSION['user']="$user"; header("Location: charactercreator/charcreate.php"); else die("Password does not match \n"); } } ?> and here's all the error says :/ : I've already checked the file permissions and they're set to 0644, what I assume is normal? So I'm really not sure why I'm getting this error... Anyone got any idea? Thanks very much in advance.
  23. Sorry for wasting your time here guys...
  24. I've found the problem... http://adspring.co.uk/engines/Ads-dis.php Is displaying for me now, The problem was because of the image size my google adblock was registering it as an advertisement, and making it not display... Totally forgot all about adblock. Thanks for all of your help guys...
  25. Nope still nothing.. I've found something very interesting though, even if I remove all PHP... and just use <img src="../adverts/1/1.png" /> Then it still doesn't echo an image... But when you view source it still links to the right place? Not a clue what's happening..
×
×
  • 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.