Jump to content

kierany5

Members
  • Posts

    21
  • Joined

  • Last visited

Everything posted by kierany5

  1. Just to be sure, you have started the session with: session_start(); Haven't you? I assume this is a snippet of the code... Make sure you put it in a form. <form action="" method="post"> <!-- inputs here --> </form> Also, you sound make sure you properly validate $lang to prevent XSS attacks. Lastly, in your switch statement you have misspelt english... In fact, you have in the select as well...
  2. I highly recommend moving to a pre-built library. I rarely suggest that, but email is a whole different beast. Take a look at PHPMailer (I've used this for years, even though they are alternatives which some argue are better). It does all the messy work for you. Unicode, emails and PHP don't work well together sometimes. The code looks correct, it least as far as I can tell. Is it only unicode characters it isn't working with? Is the file being uploaded correctly (it could be PHPs lack of unicode causing the issue)? As a side note, you are using the ereg_ functions - which are now depreciated. You should move on to preg_ functions as soon as possible, because ereg_ functions will be removed in a future version of PHP.
  3. The error message says it all... $sel_page hasn't been set before you've echoed it. It's only a notice, so it's not the end of the world. If this is on production, make sure you turn display_errors off in your php.ini (or use ini_set('display_errors', 0) if you don't have php.ini access). So, simply put, in the the code you've included this file from, you've declared $sel_subject but you haven't declared $sel_page...
  4. function yourSearch($needle, $haystack) { foreach($haystack as $i => $v) { if(array_search($needle, $v) !== false) return $i; } return false; } Something like the above? So, echo yourSearch('8R195', $item1); should give A
  5. $features .= implode(', ', $_POST['features']); Did you mean if you comment out that line, it works? Try without the dot. Also, for security, make sure you html escape the strings - the inputs may contain malicious JavaScript. Use htmlspecialchars() for this.
  6. PHP can do this. See the doc: http://php.net/manual/en/book.image.php Use imagecreatefromjpeg() then the rest is quite simple from the docs. JPGs don't have transparency, so how can you remove it?
  7. Hi, Your form names are different. Line 228/244 should be: <input class="field" type="text" name="userName" id="userName" value="" size="23" /> Line 231/252 should be: <input class="field" type="text" name="password" id="password" value="" size="23" /> Warning: You are susceptible to an SQL Injection - which is very, very bad You MUST Validate and escape user inputs. E.g. $userName = mysql_real_escape_string($_POST['userName']); Also note that you should move to mysqli or PDO since the mysql functions are now depreciated. Mysqli in procedural form is very similar to the mysql functions.
  8. So that's what it is, an IDE. I had not idea what Android Studio is. When I referred to windows or linux, I meant the machine the PHP is being executed on. For example, I develop on a mac but my code is executed on one of my servers, all running a distribution of Linux. So, if your code is being run on a windows machine you'll need to download some additional libraries to send straight from the script if you don't want to use SMTP. Once again, I seriously recommend PHPMailer or some other library - they cut out the non-sense you have to go through when sending html emails, etc.
  9. I have to say, when I registered it took many attempts the get the captcha correct. After refreshing the page, it worked so I suspect something isn't fully working on the registration page... I didn't try the Facebook or twitter options...
  10. You can use the mail() function, which on linux uses sendmail (or postfix, etc). Windows requires additional tools. You could also use a library like PHPMailer. You can use SMTP using this library.
  11. $myValue = (isset($_GET['myKeyName']) ? $_GET['myKeyName'] : defaultValue); So when $_GET['myKeyName'] is not set, it uses defaultValue. You can't include("../content_header.php?search=true"); ​You can access $_GET variables set on the parent script in the child script.... E.g. I go to /example.php?search=test In example.php: <?php include('include.php'); ?> In include.php <?php echo $_GET['search']; ?> Hope that makes sense. {addition} $_GET is a Superglobal, as documented here: http://php.net/manual/en/language.variables.superglobals.php Same as $_POST, $_SERVER, etc. These are set when PHP starts running the script. The include functions don't start a new PHP process, it brings the include script into your current script and runs it.
  12. Here is a different idea: shared memory. Take a look at the doc: http://php.net/manual/en/book.shmop.php Using semaphores to lock/unlock the shared memory. Then it as readable and writable by all php scripts running. Very quick as well. Much quicker than using a database and with much less overhead. Though, for a simple variable memcached or something could perform the same function. I needed more control than memcached provides in my system for certain tasks...
  13. I find it very difficult to interpret your question. I believe you are asking if you should use a different database for each branch of a shop/business. If so, it depends. If you are using the same system for each branch, then I would say no. Just give each branch an ID in a branches table, then use this in your stock table. But, by the sound of it, you're in a little too deep...
  14. Use <input type="checkbox" name="course[]" value="<?php echo $line["course_id"]; ?>" /><?php echo $line["course_name"]; ?> Then $_POST['course'] is an array(); if (isset($_POST['save'])) { for($x=0, $c=count($_POST['course']); $x<$c; $x++) { $course_id = mysql_real_escape_string($_POST['course'][$x]); // I recommend doing more validation, e.g. checking if it exists in the courses table... mysql_query("insert into organization (course_id) values ('$course_id')") or die(mysql_error()); } } Note the real_escape_string - I am preventing an SQL Injection by escaping the value... Always escape and validate user inputs. Also note the mysql function are depreciated. You should be using mysqli or PDO instead, as mysql WILL be removed in a future version of PHP. Hope this answers your question.
  15. Not quite sure what you are asking exactly. If you want to redirect them, then <?php header('Location: http://www.example2.com'); die(); If you want to get the content from example2.com, then you have a couple of options. Remote file open or cURL (if you have it installed) are the two the spring to mind. Personally, I would use cURL: <?php $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://www.example2.com'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // If 0, curl_exec will print data $content = curl_exec($curl); ?> This can slow down your script quite a bit though...
  16. Following mac_gyver's reply, which I completely agree with, something like this is what you should do: name_table: id int(11) primary key auto increment name varchar(10) meaning varchar(10) So it would hold data like: 1 | test | meaning1 2 | test | meaning2 3 | test | meaning3 4 | blah | meaning1 5 | blah | meaning2 6 | name | meaning 1 You could prioritise meanings by adding another column or putting them in order by ID. Then just loop through like: $check = $conn->query("select * from name_table WHERE name='".$conn->escape_string($name)."'"); while($row = $check->fetch_array()) { // Stuff here for each meaning }
  17. Hi, This pretty much confirms that the main issue is the PHP setup with your current hosts. I have used many shared hosting in the past, I don't want to start advertising but Google has many results... I haven't used a third-party shared hosting service in 2 years now. I've now got a multi-server setup around Europe in a few data centres... Most shared hosters offer PHP support now, just don't be caught in by all the unlimited offers they provide. You don't need it, and they don't really supply it. But that isn't much of an issue. If your client isn't stuck on a contract, moving hosts could be a quick solution (well, 48 hours), but recommend a host that will last. The other solution would be to track down the errors in the code and solve them... Just saying... Hope it goes ok though, which ever direction you go in.
  18. Hi, The mysql_ thing won't be causing the critical error (unless it is not installed, which I assume it is). To enable error reporting without using php.ini (which is often untouchable on shared hosting), you should put in code (at the top somewhere), <?php error_reporting(E_ALL); ini_set('display_errors', 1); ?> WinSCP shouldn't be an issue, nor should having no CRLFs. $_GET['show_id'] is not set when there is no ?show_id in the URL. So you are assigning a value that does not exist to the variable. This may be causing issues with your current setup. To be honest, I reckon you are using a very strange PHP setup. I've never known a script to break because a $_GET variable hasn't been set. On the catalog page, I'm getting ERR_EMPTY_RESPONSE. Simply put, the server is sending no data...
  19. If $check is false, then there is an issue with your query or MySQLi connection... AND PLEASE, ESCAPE $name BEFORE PUTTING IT IN A QUERY. You've just shown the world that your code may be susceptible to an SQL Injection... (See http://php.net/manual/en/mysqli.real-escape-string.php for the function to use).
  20. There are a few options. You could do some research on apaches mod_rewrite Also, you could consider $_SERVER['PATH_INFO']; From PHP Docs: See: http://php.net/manual/en/reserved.variables.server.php
  21. Hi, Bare in mind that mysql_ functions are deprecated. You should move to mysqli or PDO for compatibly of future versions of php. As for the code, it is difficult to see where the error could be. Also note the following: When you add ?show_id=1 for example to your about us page, it works.... Well, doesn't end executing... So the line "$id_to_show=$_GET['show_id'];" is probably to blame... Now, usually this is a warning not an error, so your config must be different (I assume). You could change it to: $id_to_show = (isset($_GET['show_id']) ? $_GET['show_id'] : DEFAULT_ID_HERE); Please make sure you validate/escape this before using it in a query... Hope this helps
×
×
  • 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.