Jump to content

ash992

Members
  • Posts

    56
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

ash992's Achievements

Member

Member (2/5)

0

Reputation

  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
×
×
  • 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.