Jump to content

cpd

Members
  • Posts

    883
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by cpd

  1. If the include file is directly related to the file your executing then just put the code in the same php file as your html file. There's not really any need to create another page for it.
  2. It means you could ultimately end up testing every single variable just because you want to print it out. What is your specific example and I may be able to suggest an alternative method?
  3. Right click your web page, click "View source"/"View page source" or go through the Settings in some browsers... or CTRL+U...
  4. At some point your going to need to include the username and password in order to connect from PHP... If you don't you can't connect. Moreover, PHP will execute before the page is output so unless you decide to print your sensitive data, your information should never be seen...
  5. You haven't actually outlined your issue? If your trying to run a check to ensure at least one checkbox is ticked you could do it in various ways. I'd prefer an array in the follow manner. <input type="checkbox" name="checkbox[course1]" /> <input type="checkbox" name="checkbox[course2]" /> <input type="checkbox" name="checkbox[course3]" /> And in my PHP if(isset($_POST['checkbox'])){ // Do something You can then test if only "checkbox". Cycle through the checkboxes to determine which ones are set. Furthermore, if your form action redirects to another page you will need to set the post data to a session and test for it in your input fields. Your new to PHP so that concept may be a little daunting. If you don't understand let me know but do still explain your issue further as its currently very vague and more help may be given from other members if you explain in far more detail.
  6. Or you can just specify what you want in the mysql_fetch_array function. $result = mysql_fetch_array($stmt, MYSQL_BOTH); // Default $result = mysql_fetch_array($stmt, MYSQL_ASSOC); $result = mysql_fetch_array($stmt, MYSQL_NUM);
  7. After running your logout page the $_SESSION variable will no longer be accessible because you've run the session_destroy() function. In order to access your $_SESSION variable again you must run the session_start() function once more. You can also use isset() to ensure your code functions even when session_destroy() hasn't been called. You've probably done a similar thing with your redirect. if(isset(SESSION[loggedin]) && SESSION[loggedin]) // Code
  8. You need to use either a Stored Procedure or multiple queries with the logic in your PHP. You can not accomplish this through a simple query. I did, after playing around, create this for you but it's only half of what you want. The other half isn't possible in a simple query. SELECT `aircraft`,COUNT(`aircraft`) AS `Amount` FROM `deliveries_orders_boeing` GROUP BY `aircraft`;
  9. You can try redefining the specific inputs by addressing their wrapper and then the input it-self. input {font-size: 12px;} div#wrapper input {font-size: 16px;} <div id="wrapper"> <input name="myName" /> </div> The second line of CSS should take higher precedence over the first - from what I can remember anyway.
  10. Apply an "isset()" to where-ever your using the variable but it could be argued, and I would argue, that's bad execution practice. <?=(isset($message) ? $message : "");?>
  11. After reading everything and arriving at kicken's I've noted he's written pretty much what I wanted to say so I won't go on but will emphasise a few of his points. There is no purpose to splitting your data across multiple databases - other than perhaps organisation issues which in my opinion is not a satisfactory reason - unless you create specific user accounts for each database and even enforce permissions on specific tables. Having previously juggled many databases in a single system, I ended up with around 7 or 8 databases all of which had their individual user accounts. It can be seen as an added layer of security however, if someone can inject using one account they may be able to increase their permissions by logging in as a higher level user through injection. For this reason, you should start at the first point of contact the "hacker" will have with your application and ensure its fully secure before moving on to "securing your data"; in your case, any input should be processed appropriately. You can then consider encrypting the data inside your database. If you want small steps Debbie, start at the front and work your way back. Don't start at the back and work your way forward if that makes sense? SQL Injection is a more pressing issue in my opinion. All that said and done you may actually already have the best damn security on the planet but the point still stands. P.s. Referential integrity can't be applied across databases. Furthermore, if data A and data B have a relationship which requires referential integrity, they shouldn't be in separate databases, the databases should be merged or data transferred.
  12. You don't want to be stripping slashes from a password as it could contain a slash. Also, if you store your passwords as a hash you don't have to worry about SQL Injection from the password POV as it'll get hashed when you check it.
  13. What's line 120 and line 137?
  14. A complete guess but if your fields are named appropriately, isn't Module_Code a unique code for each module, not "BSc Hons". Could be completely wrong so still answer PFMaBiSmAd's question regarding what data should be returned.
  15. What's your error because you haven't actually told us yet.
  16. Assuming you want to add multiple bits of data and your insert() function can handle that you need to add square brackets to the end of the two array variables as follows: foreach($bcc AS $userID){ $recipientData['userID'][] = $userID; $recipientData['bcc'][] = 1; } Else you may as well just assign them values instead of cycling through. Even then the array structure is slightly dodgy; consider changing it to the following: foreach($bcc AS $userID){ $recipientData[] = array('userID' => $userID, 'bcc' => 1); }
  17. Aww I do have to apologise as the fetch functions do return false if there aren't any rows, they do not error; I begun thinking all the fetch functions behaved like the query function. Try going about your posts without being degrading in future. Posting "Oh please." doesn't help anyone especially after your initial post. I am in this situation however, wrong, but only due to assumption. Sorry for misleading people.
  18. cpd

    CSV insert

    Short answer, yes. If you want to understand how this is working then no. RE your .csv file. "product_title"is $data[0] "short_description" is $data[1] "full_description" is $data[2] "QTY" is $data[3] "Pirce" is $data[4] "image.jpg" is $data[5]
  19. If by "no data to be returned" you mean "isn't SELECT, SHOW, EXPLAIN, or other type of query that creates resultsets" then yes. If you mean to include (executable) SELECTs that don't return any rows then no: mysql_query() will always return a resultset resource regardless of how many rows it found. Uh, no. OP: mysql_query() returned false because the query couldn't be executed. Print out the query and check for problems. There is probably something wrong with it. Okay, seeming as you want to get extremely picky, I'll re-write my original post. Any statement which returns a resultset will output false if there is an error with your query else it will return a resource ID. If that resource ID points towards no data your mysql_fetch functions will error as it expects the resource ID to point at a memory location in the server memory which contains the data. This is why the error you receive is a "invalid resource ID" because it needs a resource ID which has data; therefore it can not fetch the data and parse it into an array. Detailed enough? Or should we discuss how the data is taken from the memory and parsed into an array?
  20. Get some code up pal. Are you using any sort of JavaScript for validation at all? Do you run any checks for the browser type before executing your code?
  21. Whitespaces are useful to split your code up but that's just extreme buddy. Your receiving an error when you don't have any returned data because mysql_fetch_array expects parameter one to be a resource ID returned from a mysql_query. If there is no data to be returned, mysql_query will return false, therefore your variable you think contains your resource ID is actually equal to false resulting in your mysql_fetch_array function outputting an error.
  22. cpd

    CSV insert

    Like I said it complete depends what column your QTY is and what column your Prices are. Unless you give us your spreadsheet we can't tell you but its fairly simple. QTY,Prices,Image maps to $data[0],$data[1],$data[2]
  23. No None isn't SQL. I think your looking for NOT NULL. With regards to your problem you can't use a smallint for a value greater than 32,767 as a smallint is a signed 16-bit integer meaning it can be negative and in the range of -32,768 to +32,767. It's impossible for it to hold a value of 99,999 because there aren't enough bits. You require a minimum of "int".
  24. cpd

    CSV insert

    It depends where in the array the short description is. If its in the first column then you want to put it in as $data[0]; second column is $data[1] and so on.... Also, if your trimming everything you put through the saveToDB() function you should include the trim in that function; else your re-writing code for no reason.
×
×
  • 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.