Jump to content

JD*

Members
  • Posts

    230
  • Joined

  • Last visited

About JD*

  • Birthday July 21

Profile Information

  • Gender
    Male
  • Location
    Tulsa, OK

JD*'s Achievements

Member

Member (2/5)

0

Reputation

  1. So you want to have the literal words in there? Use the html characters instead <?php $edit_content_de = "<textarea>Text</textarea>asd"; ?> <p><?php echo '<textarea name="content" id="codeTextarea" style="width:90%; height:500px;">'.$edit_content_de.'</textarea>'; ?></p>
  2. Thanks for all of the helpful answers. I guess that I'm going to go with my first instinct to make my own class that wraps around the existing functions. This way I can sell it as "Hey, just replace mysql_num_rows with $db->num_rows() and we'll never have to update that line again, we just make sure the num_rows function inside of db.php returns what we want." As for using an existing product, I would love to, but this place has gotten burned one too many times by adopting frameworks that have suddenly gone out of style. It's like a Murphy's Law thing: once they adopt it, the project implodes, so we don't want to jinx it.
  3. Hello all, I am trying to make a determination about the best way to move forward with my database code for both personal projects and for the company I work for. For my own projects, I used to use mysql functions but have started to switch over to PDO. The company I work for is still using mysql functions and they are a bit wary about switching over to either mysqli or pdo, as they have a lot of code to go through and they don't want to make a bad decision. So I started working on a database class that would replicate all of the mysql functions they were used to (fetch_assoc, fetch_array, num_rows, etc) and decided to make it so that, via a config, you could use mysqli OR pdo and then, in each function, it would do it's best to get the expected result. This way, the code for the company would only ever have to do something like: $db->query($sql); if($db->num_rows() > 0) etc... But the more I read up on PDO (which I have been using in a more proceedural way), it seems like this is already a wrapper, so in effect I'm wrapping a wrapper. So, bottom line, what are others doing to future proff their database code? I like the idea of a class with generic function names, because if there is ever another style to use (mysqlii?) we can just write up the proper functions inside of the existing class and they'll work without a hitch. But is this something that pdo already delivers? I know it's good for dealing with multiple types of databases (mysql, mssql, oracle) but this company will only ever be working with mysql, so I don't have to go overboard with considerations for that. Thanks for any help/advice! JD
  4. Just to tack on, make sure that you escape anything that comes from a user/form or else you'll get an SQL injection attack $varAssign = mysqli_real_escape_string($_POST['formAssign1']); $varDue = mysqli_real_escape_string($_POST['formDue1']); $varLink = mysqli_real_escape_string($_POST['formLink1']); $sql = "INSERT INTO table (assign, due, link) VALUES ('$varAssign','$varDue','$varLink')";
  5. This is a bit more jquery than php, but here's what wrong. First, in your javascript, you need a closing ); and you need to pass your object inside some type of POST variable and stringify it, like this: $.post("save.inc.php", "stuff=" + JSON.stringify(jsonList), function(res) { alert(res); } ); Then, in your PHP, do the following: $array = json_decode($_POST['stuff'], TRUE); print_r($array); That should get you where you want to go
  6. I think the question is, to what end do you want to store the data? Is it for archival purposes? or is it something that is going to be added to all the time. If you're going to have different xml files for each listing, that might be fine, but you're still going to have a lot of parsing to do to get your data. As for speed, here is some reading to do: https://www.google.com/search?q=php+xml+vs+database&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
  7. Do you want to make it automatically detect the serial number? Or is it a form that the person fills out? If it's the former, you'll need to involve some javascript. If it's the latter, you can grab the last four digits of the submitted serial number and then do a query. Try looking at substr. You can tell it to start at the strlen($serial) - 4 and then use that to query your database.
  8. It seems pretty good, but if you want to try something a little easier you can look into the phpmailer class, which allows for attachments, connection to smtp and a lot of other stuff. Check it out here: phpmailer
  9. Try this: Echo out your SQL statement to the page, then do a die(); Then execute your SQL statement directly into the database (MySQL Workbench is good for this) and see if you get the error there. ////////////////////////////////////Check Phone Exist function phoneNoExist($phoneExist) { $sql = "SELECT * FROM table WHERE homenumber='".$phoneExist."'"; die($sql); $rs = executeSql($sql); if(mysql_num_rows($rs) == 1) { return true; } else { return false; } }
  10. Just to add on to Christian, you don't necessarily need to store the timestamp in a database. Since these files are created new on the server, their modify date will be the date they were uploaded. Assuming they don't change once uploaded/virus scanned/moved to download folder, you can just run a script that loops through your directory and checks that date. This can be done multiple ways, too. If you want to make it a little more universal, make a perl/cgi script or a php script and have your cron job execute that. At my last place I would run a nightly php script that would do stuff like this and I would have it email me a report of what was done. It was really easy to maintain and add on to.
  11. Are you looking to have a negative number return? If not, you may want to change the order of your equation. Here it is cleaned up a bit. Also, per Andy123, you really don't need the substring calls, and you should have your numbers as numbers, without quotes: $deposit = 300; $full_price = 1000; $extra_cost = 10; $remaining_balance = ($full_price - $deposit) + $extra_cost; echo $remaining_balance;
  12. Do you want your program to automatically create thumbnails from your original image? Is this a one-time only thing, or will you be uploading pictures via a page and need it to automatically do this?
  13. If you don't want the page to reload, you'll need to use some javascript to make an ajax request. It would go something like this: On click, make an ajax request to a php file with the "href" of the link In the PHP file, open the requested file and read the contents. Return the requested array, which the ajax handler will be listening for Update the text area with the return. Sound like what you're looking for?
  14. Ok, so it looks like your variables are empty. Can you post the rest of your code?
  15. Ok, so your next step(s) is to put in a die() ( like die("Got Here"); ) statement in side your post block and make sure that your code is being executed properly. If everything is looking good, echo out your sql query and make sure that it's set up properly: die($sql1); The die statement prevents the rest of the page from finishing and helps you track down what's going on.
×
×
  • 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.