jcbones
Staff Alumni-
Posts
2,653 -
Joined
-
Last visited
-
Days Won
8
Everything posted by jcbones
-
One of the reasons we include individual parts into a main template, is so that when we redesign the page, we only have one page to do, not multiples. Therefore, it is less prone for errors.
-
Is this for dates only? If so, you should be storing in a date, datetime, or timestamp column. Mysql has a vast amount of functions for working with dates, but the column has to be the right format.
-
This is actually one error. It namely being $sk['story']['media'] is not a valid array index, which means it doesn't exist. Therefore, foreach throws an error that says it is invalid. So, fix the array (or the index) and it should work. PS. Ginerjm the OP did point it out, you just have to sort through that long list of code to find it.
-
There really isn't enough there top help you. There are only portions, and an arbitrary insert method, that only leaves more questions than it answers. You need to post the query handling at least. You can post code inside of [ code ][/code ] tags.
-
It isn't a rule that you post the code, it just helps you get help faster. I'll look, and get back to you.
-
I really wish they would disable the attachments on the forum. Some of us are on our mobiles, and are not going to download scripts. It just isn't feasible. You can post these scripts via copy/paste.
-
So which is it? $myPost = new nlEmails($row["id"], $row['email'], $DBH);
-
This question is impossible to answer. Mainly because we have no idea how these variables are coded, nor how the database retains the refid, of which is not in your structure details. Things we need: 1. An actual structure dump of the database. This can be obtained by: DESCRIBE $members_table_name or, by exporting it from a database software like phpmyadmin. 2. How you are tracking, setting, storing the refid, $referrer, etc. Without those items, it just seems impossible to me.
-
How are you "sure that I am passing .jpg image"? Are you checking it? Are you checking the mime? Are you checking the extension? Are you sure it isn't a script that has been faked as an image? Basically, show us the code.
-
preg_replace() takes an array for patterns also. I'm not sure if it is faster, but it would be worth benchmarking.
-
1. Don't use mysql functions, they are depreciated. Use PDO or mysqli. 2. You are not sanitizing any inputs, this is bad, and can lead to server hijacks. 3. You do not have error checking or display errors set (you should have this enabled for all development), or you would see multiple problems with this code. Top of script error_reporting(-1);ini_set('display_errors',1); 4. You are checking each username against your database password. 5. You are trying to query the database with an array from the database. $row = mysql_fetch_array($sql);$bancheck = mysql_query($row); 6. You are trying to use a constant that hasn't been defined, perhaps you mean it to be a variable (php will try to interpret it as a string, which means it will always fail in this instance). if($row['active']==0 && [b]count[/b]==0) { That is all I see at a quick glance.
-
Writing GET content (from form.php file) to a separate text.txt
jcbones replied to sataiuto's topic in PHP Coding Help
That code should work, as I see nothing systematically wrong with it. file_put_contents() is easier, and less coding. $name = trim($_GET['name']); $comment = trim($_GET['comment']); if(file_put_contents('data.txt',"<p>$name and $comment</p><hr />\n",FILE_APPEND) !== false) { echo 'File was written successfully!'; } else { echo 'The file failed to write.'; } -
Alright, you made me read up on some things. You could create an inline style, that would override your stylesheet, unless it is marked !important.
-
This is a css problem, and not a PHP one. There are guru's that can do amazing things with css, however, I can only do basics without looking a lot of stuff up. I will try and divulge a little bit of help, but I mention these things so that you can take what I say and research it. It may or may not be incorrect. CSS has priorities. Which means that styles written in certain scopes override other styles. For instance, a style for an id attribute overrides styles for class attributes. Edit: scratch that: You may need to study your stylesheet to see if the dropdown styles are marked !important.
-
Specify the exact path to the file: $tracking_file_location = "/home/www/exact/path/to/dispatch-manager/logs/tracking_file.txt"; Relative file paths will always cause problems. Especially, if the current file is included in a file that is located in a different location.
-
I'm starting to think this code is provided as some type of school work. We have seen this exact, or nearly exact, code a dozen times in the past week.
-
You need to check for browser cross capability. I'm pretty sure IE sends png's as x-png, I think gif's are different as well, but that escapes me.
-
This is the reason why you should always put a fully qualified URI in an anchor tag. Putting relative links into an anchor tag, if not well thought out, will create the problem you are having. In other words: BAD <a href="/my/links">Links</a> Good <a href="http://my.site.com/my/links">Links</a> You will have less of these problems.
-
How to select question from mysql tables randomly ?
jcbones replied to JosephHanh's topic in PHP Coding Help
Don't use ORDER BY RAND(), if you want random from the database, check http://http://explainextended.com/2009/03/01/selecting-random-rows/ first. After that, I like Cronix suggestion, using the session to store used question id's, so you can check against it for repeat questions. -
First, you should be storing the user_id and possibly the username in your session data. Therefore, you will not have to grab that each time you want to query for more data. Just use the session for that info. Secondly, Frank_b is right in a sense that there is no need to associate user_id's with individual pics. Just use the database to relate the pic back to an individual user. With a table of pic names, you can relate much more than one pic to the user. To get the image to show up on the page, you just use a standard HTML img element. I always check to make sure the file exists first. $file = '/home/me/www/images/' . $row['filename']; if(file_exists($file)) { $file = $row['filename']; } else { $file = 'default.jpg'; } echo '<img src="http://mysite.com/images/' . $file . '" alt="No image" />';
-
event_id is NOT auto incremented. It still stands that the event_id is passing NULL value. You also shouldn't need to re-bind any values except the $name value. That is all that should be in the loop. Maybe a: echo '<pre>' . print_r($_POST,true) . '</pre>';
-
By making the column "unique key", you are telling mysql that the column should not contain duplicates. So then mysql will not only reject the insert, it will throw an error. That is why you add the ignore to the query, so that mysql ignores the error.
-
The reason to generate a unique filename isn't so that the images will not be overwritten. It is instead a security measure, so that you control what the image is, and that it is saved as an image. Some go so far as to create a new image, so that someone can't upload an image that has code in a comment tag (inside the image). You must think of security when accepting uploads of any kind. Like making sure the upload is coming from a client, and not a script. Or, that the $_FILES superglobal hasn't been hijacked (the manual tells you that it can), which is why you shouldn't trust it. For instance, I could upload a php file to your server through your script, even if you are checking $_FILES['file']['type'] to make sure it is an image.
-
I'm sure you could. Never tried it, don't see the point. .htaccess is Apache file, there is no need for PHP to see or read it. IMO, there is no need to apply an Apache rule to PHP, unless, you are doing things in Apache that is better left to PHP. Perhaps you could grab the file with file_get_contents(), or if you need it in an array file(). The parsing would be a custom script.