Jump to content

guyfromfl

Members
  • Posts

    286
  • Joined

  • Last visited

    Never

Everything posted by guyfromfl

  1. The table doesn't reference anything, otherwise I wouldn't try this. It's just a table of customers, but the sequence in place now overlaps older records in the way of handling customers, so there is data collision. I did see a work around where I can drop the table, redefine the AI # and put it back on the table.
  2. I have a database that contains a Primary Key, but my boss wants me to renumber it to (current PK value) + 800000... So, PK 1 would become 800001, PK 2354 would be come 802354 etc... Is there a simple way to do this or should I write a script?
  3. Your ISP needs to set the permission to 755 on the file giving you the 500 error. Do you have FireBug installed? What does the returned data say?
  4. I am reading hundreds of CSVs to import into a DB. Some of the column names contain the same data but have different names across all the files. For example, one file will say Phone where the other says EveningPhone...both contain the same data, different names. I am trying to rename everything to EveningPhone because I had most of the code done when i realized there were different header names in different files. Too lazy to replace all i guess.. I am creating an assoc array to match the data then off to the db it goes.. The problem is I cannot get the keys to rename to one convention. Here is the function where it happens: public function readCSV($file) { /** * @todo: LOAD THE FILE INTO A MULTIDIMENSIONAL ASSOCIATIVE ARRAY TO DETERMINE THE FILEDS */ // Read the first line to get the headers $headers = fgetcsv($file); if (!array_key_exists('EveningPhone', $headers)) { if (array_key_exists('Phone', $headers)) { $headers['EveningPhone'] = $headers['Phone']; unset($headers['Phone']); } else { die("other"); } } format::neat_r($headers); // basically print_r but adds a new line to read it easier... die(); At the end, I still get EveningPhone not defined errors from a file that uses Phone as the phone number.. Anybody have any ideas?
  5. Russell, Thanks, I was thinking about doing a CRON job, but I was just wondering what you guys had to say... I think I'm going to start on that, instead of lurking around in a forum on the clock... ha Thanks!
  6. Make sure you are using the correct DOCTYPE declaration... IE is the most picky about this and how it renders your code. I just spent a week redoing alot of code and found that fixing the DOCTYPE was the main culprit the whole time.
  7. I just have a general question about when other programmers remove rows older than say a year old.... Do most of you: 1) set up a CRON job to run daily at 3:00am 2) Add a routine at login for each user 3) Add a routine when a user moves into a certain portion of the application 4) A maintenance routine that an administrator manually has to envoke Or is there another way...I have done some research but most of the things google has showed me is the how not when to do this...
  8. Ok I figured it out, kind of. I added a div #step2 after step1 and it stopped working. If I remove div#step2 it works. The problem is I need step 2 and wanted it in another div so I can make it accordian. Anybody know why when I add a div after step1 it disables the links?
  9. I have a jQuery UI Dialog that gets links for a user. I don't know exactly what I just did, but the links appear, but are not clickable. I looked in FireBug and they are surrounded by anchors, and all ' and " seem to be closed correctly. Hopefully another set of eyes can help me spot the problem. Here is the div container: <div id='step1'> <h1>Step 1</h1> <p>Download and sign your contract.</p> <h3>Please Select A Format:</h3> <div id='downloadLinks'> <!-- Container for generated download links --> <div id='pdfLinks'></div><div id='jpgLinks'></div> </div> </div> Here is the success function for the dialog that alters the pdfLinks and jpgLinks divs: if(log['success'] == true) { $("#jpgLinks #pdfLinks").empty(); /* DOWNLOAD IMAGES */ for (var page=(contractId['pages']-1); page>=0; page--) { //$("#downloadLinks").prepend("<a href='contracts/jpg/"+contractId['contract']+ "-" + page + ".jpg'>Page " + (page+1) + "<\/a>"); $("#jpgLinks").prepend("<span><a href='#' onclick='log(\"" + contractId['contract'] + "-" + page + "\", \"DOWNLOAD_JPG\");'><img src='img/JPG-Link-" + (page+1) + ".png' alt=''><br>Page " + (page+1) + "<\/a><\/span>"); } $("#jpgLinks").prepend("<h5>Standard Image Format<\/h5>"); $("#pdfLinks").prepend("<span><a href='#' onclick='log(\""+contractId['contract']+"\", \"DOWNLOAD_PDF\");'><img src='img/btnDownloadPdf.png' alt='Downdload PDF' /><br>Download Adobe © PDF<\/a><\/span>"); $("#pdfLinks").prepend("<h5>Adobe PDF<\/h5>"); $("#dialog-confirm").dialog("close"); } else { alert("There was a problem! Please contact customer support."); showDisclosure(); } /* end else */ Thanks!
  10. That article is AWSOME. Perfect for what I want to do. I just need to go backwards! WAY cleaner than my solution. Thanks a million!
  11. For other inquiring minds: SELECT * FROM tabl WHERE dateField >= CONCAT( DATE_SUB(CURDATE(), INTERVAL WEEKDAY(DATE_SUB(CURDATE(), INTERVAL 5 DAY)) DAY), ' 00:00:00'); Then change the interval number to whatever day of the week you want.
  12. Does anybody know how to do something like: SELECT * FROM tbl WHERE insertDate IS BETWEEN NOW AND LAST THURSDAY
  13. I would protect the information in the links, not the links themselves. The best way would be to create a login class, then check the user is logged in, each time the link is referred. What are you trying to protect?
  14. I put an ' in the SQL on accident... $sql ="INSERT INTO account (username, userpassword, email, role, location, interest, homepage) VALUES (:username, :userpass, :useremail, 'user', :userlocation, :userintersets, :userhomepage)";
  15. hmm... I copied that directly from my code but edited your db and vars into it... What line is 110?
  16. In PDO You have to bind the data first public function insert_data($user_info) { try{ $dbh = new PDO("mysql:host=localhost;dbname=phpfaqproject",'root',''); //echo "connected"; } catch(PDOException $e){ echo $e-> getMessage(); } $sql ="INSERT INTO account (username, userpassword, email, role, location, interest, homepage) VALUES (':username, :userpass, :useremail, 'user', :userlocation, :userintersets, :userhomepage)"; $stmt = $dbh->prepare($sql); if($stmt->bindParam(':username', $user_info['username'], PDO::PARAM_STR) && $stmt->bindParam(':userpass', $user_info['password'], PDO::PARAM_STR) && // The rest of the data in the array ){ $stmt->execute(); $insertId = $dbh->lastInsertId(); $stmt = null; } else { echo "<p>Problem Binding Data</p>"; } You could also insert by numeration then foreach through, but you would have to make sure all the data is in the correct order throughout your application. Thats why I usually use the reference method... Also, why don't you set the role field in the database to default as user?
  17. I have a script that takes a 2 or 3 page pdf, uploads it and hashes the file name to something that isn't guessable. We now want to add an image of each of the PDF for users who don't have Adobe Reader. Some pdf's will be 2 and some 3 pages. Should I: A) Let convert name the different pages "*-0.jpg, *-1.jpg..." and then use a recursion function (it's already written for another reason) to crawl the folder, B) Use a PHP/PDF library to determine the number of pages, then add the value to the database's corresponding row. C) Use a hybrid of both D) Any better ideas??? Thanks
  18. Ken, Thanks! That looks like exactly what I was looking for. Thanks alot!
  19. I am trying to protect a file that has access to sensitive data. Basically what I am looking for is a way to check that only $_GET['lead'] is passed to the document. Is there a way to determine if #1 only lead is passed, and #2 what other variables might be sent in a GET request? I am emailing a confirmation email to our clients, that has only the lead variable in the provided link. I want to check against something like" http://website/phpfile?lead=124&foo=bar Where I can throw an error because foo was passed.
  20. I am setting $pin=null to reset it. I was going to have another testing condition, but took that part out and left the initializaiton in, wasn't really paying attention to that i guess. I think the problem is I added that do loop before I had prepared all the variables, leaving $email null, and it was tripping it up.
  21. I have a Unique Constraint setup on (emailAddress and pin) to allow multiple email addresses be the same and multiple pins but not the same emailAddress and pin value together (unique(emailAddress, pin)) Anyway, I am trying to generate a pin through a random seed, but I can't get my code to work properly to test if the combination already exists. Here is the chunk that does not work: $tries = 0; $foundRows=0; do { $pin=null; $tries++; $pin = str_pad(rand(0,9), 4, "0", STR_PAD_LEFT); $stmt = $dbh->prepare("SELECT COUNT(*) FROM ajax WHERE emailAddress=:email AND pin=:pin LIMIT 1"); if ($stmt->bindParam(':email', $email, PDO::PARAM_STR) && $stmt->bindParam(':pin', $pin, PDO::PARAM_INT)) { $stmt->execute(); $foundRows = $dbh->query("SELECT FOUND_ROWS()")->fetchColumn(); echo "<br />$foundRows<br />"; } else { die ("<p>Could not bind to data verification</p>"); } } while ($foundRows > 0); This is always returning $foundRows=0 so always exiting the loop, and giving me a constraint error. Any ideas? Maybe a better way to do this?
  22. No C-panel... I'm running an open linux box, thats it. The checkIp function should be doing the same thing, and database is only granted to localhost...
  23. I have an old db class that I created a while ago, and might switch to PDO. I just don't want to recode the whole site. The class was working really well to protect my db but they (spammers) have found a way around all my security and are posting links to porn, pills and russian. What I have is in the db class, there is a query function. Every query is sent to this function where it is sanitized and checks a table of blocked ips. I belive they are somehow bipassing this and going directly to the data base, becasue I am getting attacks from the same IP that should be blocked. The function looks something like this: function query($sql) { if ($this->checkIp($_SERVER['REMOTE_ADDR'])) { $sql = $this->sanitize($sql); $result = mysql_query($sql); return $result; } else { die("<h1>You are banned for abuse!</h1>"); } } Does anybody have any suggestions?
  24. Thanks for the input.. I'm devin on localhost so that is one consideration I might not have seen until later. I moved it to the outside of the $.getJSON method. I found the problem I think, here is the new code for any other noobs that run into this: function sendValue(str){ var url = "test1.php?sendValue=" + $("#txtValue").val(); //var url = "text1.php?sendValue="; $.getJSON(url, function(result){ var outString = "<h1>Results</h1>"; $.each(result, function(i, field) { //$("#display").append(field['id'] + ": " + field['name'] + "<br>"); outString += field['id'] + ": " + field['name'] + "<br>"; // alert("g" + outString); }) }); $("#display").html(outString); } Also, you have to cast the JSON data in the php: while ($login = mysql_fetch_assoc($result)){ $json[] =array("id" => $login['id'], "name" => $login['name']); $i++; } header('Content-type: application/json'); echo json_encode($json); I hope this helps someone!
  25. I cannot figure this out. I have a php page that searches a database for like results, json_encodes it and returns it to JavaScript. Firebug's console shows all the correct data is being returned from the php file. I cannot, for the life of me, get jQuery to loop through each json element and display them. What am I doing wrong? Here is the jQuery code: // the link to the php file with the search field var url = "test1.php?sendValue=" + $("#txtValue").val(); // Cast the output html var outString = "<h1>Results</h1>"; $.getJSON(url, function(data){ $.each(this, function(index, item){ //alert("DATA::" + this.id); outString += '<div class="post">' + '<h1>' + this.id + '</h1>' + '</div>'; }); }); // Display the output html $("#display").html(outString); All I get is either undefined or null. Firebug says the returned JSON is: [[{"id":"1","name":"Mark"}],{"1":{"id":"2","name":"peter"}},{"2":{"id":"3","name":"mike"}}]
×
×
  • 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.