-
Posts
4,362 -
Joined
-
Last visited
-
Days Won
11
Everything posted by Zane
-
Code For Adding Tax Total To My Php Shopping Cart
Zane replied to smallc28's topic in Third Party Scripts
Do not expect to get very much help from this community by attaching the PHP file. Our community is full of people who are weary to download a file from a complete stranger mainly for security breech reasons. That could easily be an executable whose extension is changed. Especially since you are absolutely new here. Post the code (within code tags please), and rephrase your question to be more clear -
That PHP error message most always means that your query is invalid. You should put this at the end of your query statement so we can see the SQL error $query = mysql_query("SELECT * FROM Products WHERE cat='Skate' AND subcat='Footwear' LIMIT $start, $limit_img ") or die(mysql_error());
-
If reports is a folder that contains an index.php file then the url is fine. All you have to do is check whether $_GET['next'] isset and then code around it. As far as changing a php variable on click, I dont believe that is possible. You would need to store the current month somewhere like in a $_SESSION variable... then use date("M", strotime("+1 month", $_SESSION['curMonth'])) to get the next month
-
Retrieving the list of images should be one of the first things you do on this page since it is the feature of the page. The create_imagelist function should return $html... not echo it. Echo the return of the function..... dont echo inside the function. Try doing that and see what happens. I'm not positive that will indeed fix it... definitely a shot in the dark.
-
http://php.net/foreach foreach($laborRates as $currentRow => $theRow) { //Assuming you have a column called rate in your labor_rates table, this would echo all from that column echo "Row Number $currentRow contains this" . $theRow['rate'] . "in the rate field."; } Simple as that..
-
There is no possible way of doing this with a fetch function. They were created explicitly to fetch the data from the dataset. I suppose you could get away with using a for loop and use mysql_num_rows for your threshold, but that is just ridiculous. My advice to you is to not stray from the fetch approach. Since you say you plan to select different datasets and use them outside the loop, it is probably the best idea to create an array for each of your datasets... for instance $query = "SELECT * FROM labor_rates"; $go[] = mysql_query($query, $connection); $query = "SELECT * FROM ed_scores"; $go[] = mysql_query($query, $connection); $query = "SELECT * FROM someTable"; $go[] = mysql_query($query, $connection); $laborRates = array(); $ed_scores = array(); $someTable = array(); while($row = mysql_fetch_array($go[0])) $laborRates[] = $row; while($row = mysql_fetch_array($go[1])) $ed_scores[] = $row; while($row = mysql_fetch_array($go[2])) $someTable[] = $row; echo "<b>$someTable[3]['name']</b>"; Then you can use a foreach to loop through those .. or you can access your data directly like I demonstrated at the end.
-
HTML is not security nor is Javascript. They are both client side languages, meaning they can be changed by the user as they see fit. There are plugins out there to do just that, they are also used as debugging tools. An example is Firebug for Firefox. With it, anyone can see where the data is going, which PHP files are being included, they can change the HTML .. in a live fashion, they can execute Javascript commands live as well. Do not fret though and consider Firebug a threat. It is a very very useful tool in web development. Psycho answered your question the best... though he didn't exactly elaborate on it the best, it is indeed the answer to your question Sanitize, filter, escape, sanitize, etcetera. YOU are in complete control of what goes into your database, the same way as you are in complete control of what foods you ingest. The key here is knowledge. If you want to make sure nothing bad gets into your system, you will have to code on the side of your system... known as server-side....AKA PHP. Here are a few PHP functions to start you off.. http://www.php.net/mysql_real_escape_string http://www.php.net/trim http://www.php.net/filter_var IMO, you're pretty safe with just mysql_real_escape_string. It is the only function that actually sanitizes the input for database entry. The other two are simply a way to reject unwanted things... like extra spaces ... or a malformed email address.
-
They all look compatible to me.. Quite a beefy (albeit expensive) computer though. Wouldn't have hurted to post what each link goes to by the way. The most important link is the motherboard and you have it as the fourth one down. You may want to get a CD/DVD drive as well if you want to put an OS on it. Although I'm sure you omitted it because, well, any kind would be compatible... just pointing it out though.
-
This link should help you out then http://stackoverflow.com/questions/6237898/storing-time-ranges-in-mysql-and-determine-if-current-time-is-within-time-range
-
Your PHP comparison will not work because gmdate and date or any other get date/time function will always return a string. In order to actually compare them with >'s or
-
There's no reason to store whether a restaurant is open or closed when you already have the open and close times in there. Using SQL you can tell whether it is open or close with the TIME() BETWEEN syntax combined with a CASE statement. SELECT `r_ofrom` , `r_oto` , `rid` , CASE WHEN (TIME(NOW()) BETWEEN r_ofrom AND r_oto) THEN true ELSE false END as is_open FROM `restaurant` Then you will not have to do a double query... and the open/close value will be in something like $row['is_open'] Using a ternary statement, in PHP, you can display text or images to show its status... echo $row[´r_name´] . " is " . $row['is_open'] ? "open" : "closed";
-
Give us an example of how you are doing it now...
-
So what was the problem. Enlighten those who end up at this thread in a search. Seeing as you never did post the results of the print_r function like I mentioned, we have no clue what was going wrong.
-
In order to do such a thing with one query you would need an activity table that contained .. The user id, The activity (like post or thread), an id for the post, and id for the thread, and most importantly the datetime of the action.
-
Try taking out the return breaks in your header \r and see if it works?
-
Hmm.. try putting this little snippet in and post back here what you get $result = mysql_query("SELECT * FROM tblCookbook where id='$frmID'"); while($row = mysql_fetch_array($result)) { print "<pre>", print_r($row), "</pre>"; ?> Displaying the info for the recipe:
-
I will bet it has something to do with the fact that your have an open curly brace before your class declaration {class e_online {
-
Yes, but only if you destroy the session after 15 minutes of inactivity. Otherwise, users would be declared as online/active until they click logout or they close the browser, then you would have to make sure any cookies are destroyed as well therefore they could be assumed online/active for quite some time... depending on the expiry settings you have for your sessions and cookies. Storing it in the database would allow you to create a list of who is online/active. Without the use of a database, you would have to populate some external file on every page load with a list of who is online or offline..
-
The function only acts as a convenience, there is no real benefit other than that. In my opinon, if you use extract you will loose track of where your variables come from. When I am coding I prefer to know whether it is a POST, SESSION, COOKIE, SERVER or GET variable whenever and wherever I use it.... unless I am creating a new variable with arithmetic purposes.... Such as $e = pow(($_POST['m'] * $_POST['c']), 2);
-
DST was just this last Sunday you know? Still doesn't explain why the time starts to drift 9 days ago, but still.. it most likely has everything to do with it.
-
If you posted all of your code we could help you more with suggestions.. I do not see in your code anywhere where you are defining colors or setting the background. Are you using CSS classes or what?.. Looking at your very first snippet of code I would immediately suggest the use of a switch, but then you mention that arrays have helped you out more now... I am sure there is an easier solution to what you are doing becaue you are doing nothing more than checking a value....after some apparent arithmetic that you have decided not to show (which is probably best seeing as you are only asking help with the structure and trimming the code down) but I am guessing you already have that part down pat.
-
You have already asked a very similar question here http://forums.phpfreaks.com/topic/270294-usb-drive/page__view__findpost__p__1390239 I am locking this thread.
-
Email Verification - No Number In Position 1 Of Field
Zane replied to arccomp's topic in PHP Coding Help
There was just a topic solved on this subject http://forums.phpfreaks.com/topic/270298-if-not-email-address/#entry1390268 If you only want to check the first character then use braces to grab it and validate it if(is_int($emailInput[0]))