
cunoodle2
Members-
Posts
602 -
Joined
-
Last visited
Never
Everything posted by cunoodle2
-
very nicely done!! Congrats
-
Well I can pretty much guarantee you that $result2 and $useranswer2 will NEVER be equal based upon your code. You have the answer being set to a posted item.. $useranswer= ( $_POST["Text1"]); But you have the result set to the of a mysql query call.. $result = mysql_query($query); So in essence the only way this would be true would be if the user's input was basically a multidimensional array. I'm not really following what you are trying to do here so if possible provide some examples and we will be able to better help. To learn more about mysql_query() function call see this.. http://php.net/manual/en/function.mysql-query.php
-
<?php function GetDays($sStartDate, $sEndDate){ // Firstly, format the provided dates. // This function works best with YYYY-MM-DD // but other date formats will work thanks // to strtotime(). $sStartDate = gmdate("Y-m-d", strtotime($sStartDate)); $sEndDate = gmdate("Y-m-d", strtotime($sEndDate)); // Start the variable off with the start date $aDays[] = $sStartDate; // Set a 'temp' variable, sCurrentDate, with // the start date - before beginning the loop $sCurrentDate = $sStartDate; // While the current date is less than the end date while($sCurrentDate < $sEndDate){ // Add a day to the current date $sCurrentDate = gmdate("Y-m-d", strtotime("+1 day", strtotime($sCurrentDate))); // Add this new day to the aDays array $aDays[] = $sCurrentDate; } // Once the loop has finished, return the // array of days. return $aDays; } ?> I just did a google search for.. "php function get all dates between" And I got this for the first result.. http://edrackham.com/php/get-days-between-two-dates-using-php/
-
Please enclose your code in the "code" tags.. <?php $i = 1; $month=array('January' , 'February' , 'March' , 'April' , 'May', 'June', 'July' , 'August', 'September' , 'October' , 'November' , 'December'); foreach ($month as $value){ print "<option value =\"$i\"> $value </option>\n"; $i++; } echo "<select name = \"day\"> \n"; for ($day =1; $day <=31; $day ++) { print "<option value =\"$day\"> $day </option>\n"; } echo <<<HEREDOC <select name = "year"> <br /> HEREDOC; for ($year=2011; $year >=1993; $year--) { print "<option value =\"$year\">$year </option>\n"; } echo <<<HEREDOC ?> Then on the next page just do.. <?php echo $i."-".$day."-".$year; ?>
-
What format is the user's input in and what format would you like to display it in?
-
Can you post your code? There has to be something else going on.
-
In many of the cases it does not appear as though you need curl as you don't do anything with the data. I would just use fopen to open particular URLs. That way you don't have to set any parameters. Again this is ONLY in cases where you do NOT care about returning the data.
-
Are you 100% for sure that "$snip" has the correct values in it? Try echoing $snip to the screen and see what you get. Also try a find of just "$fpos= strpos($snip, "<div id="); and see what you get. Finally can you echo $fpos to the screen AFTER you do the search and see what it actually says? Echo to the screen is one of the best way to debug something.
-
I'm not sure but this looks wrong to me... <td><b>Reviewer:</b> <br><input type="text" name="dock" size="25" maxlength="30" value="''" /><br> </td> Change to.. <td><b>Reviewer:</b> <br><input type="text" name="dock" size="25" maxlength="30" value="" /><br> </td>
-
You have this.. SELECT line.linName, line.line_id, ship.shiName,ship.shiMates,ship.shiBlogURL FROM line, ship WHERE line.line_id=ship.ship_id ORDER BY linName Use INNER JOIN instead of "WHERE line.line_id=ship.ship_id" as your method will take much much longer/resources especially once you get into very large data sets. Also for the Company property, property propery item add in a "ORDER BY company, property;" at the end. So your query should look something like this.. SELECT line.linName as line_name, line.line_id, ship.shiName as ship_name ,ship.shiMates,ship.shiBlogURL FROM line INNER JOIN ship on ship.ship_id=line.line_id ORDER BY line_name, ship_name; Then do a loop to go through all items. Roughly.. <?php $temp = ""; while($rsMenuShip=mysql_fetch_array($resMenuShips)) { if ($temp == "") $temp = $rsMenuShip['line_name']; else if ($temp != $rsMenuShip['line_name']) { echo "<br />New line name{$rsMenuShip['line_name']} starts here. <br />\n"; echo "Here are the associated ships.. <br />\n"; $temp = $rsMenuShip['line_name']; } echo $rsMenuShip['ship_name']."<br />\n"; } ?>
-
Please use the "(code)" tags on your code. Also you should look at using an innerjoin and just do 1 query. Honestly it will be much easier to help if I saw the actual queries. I.E.. SELECT company.id, company.name, property.id, property.name, property.price FROM `company` INNER JOIN property on property.companyid = company.id There are ways to shorten that using "AS" but lets just start with that for right now..
-
searls03, as I have mentioned numerous times with your posts in the past. If you ask better questions you will get better answers. Show us what query/code you are using. Then address all of the following questions.. 1. What error messages (if any) are you getting? 2. What is it ACTUALLY doing? 3. What do you EXPECT it to do? 4. Ideally provide a sample data set. There are probably more posts on your threads then anyone else due to all of the vagueness and the back and forth on all comments.
-
It comes with great honor that this is my 700th post. As a result I will try to make it extra special. First you need a form to allow for a file upload. Here is the html code for that portion.. <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form> Then you need the php to process said file upload.. <?php // Where the file is going to be placed $target_path = "uploads/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?> You can read more about this from this very very useful tutorial.. http://www.tizag.com/phpT/fileupload.php
-
I'm going to bet that he is referring to the "\n" and the "\t" Is this correct?
-
Few things.. #1. Do NOT use (<?php echo $_SERVER['PHP_SELF'] ?>). There are major major security flaws with it. #2. I think your quotes are off a little here... mysql_query("INSERT INTO cattle_det (cattle_n,first_s,second_s,third_s,calving_d,calf_s,days_m,m_yld,dry_d,d_yld) VALUES ('$_POST[cattle_name]','$_POST[first_svc]','$_POST[second_svc]','$_POST[third_svc]','$_POST[calving_date]','$_POST[calf_sex]','$_POST[days_in_milk]','$_POST[milk_yld]','$_POST[dry_days]','$_POST[days_yld]')"); Instead do this.. $query = "INSERT INTO cattle_det (cattle_n,first_s,second_s,third_s,calving_d,calf_s,days_m,m_yld,dry_d,d_yld) VALUES ('{$_POST['cattle_name']}','{$_POST['first_svc']}','{$_POST['second_svc']}','{$_POST['third_svc']','{$_POST['calving_date']}','{$_POST['calf_sex']}','{$_POST['days_in_milk']}','{$_POST['milk_yld']}','{$_POST['dry_days']}','{$_POST['days_yld']}')" if (mysql_query($query) echo "SUCCESS!!\n"; else echo "FAIL!!\n"; Also you really should be doing some variable sanitizing prior to you insert.
-
Rookie Alert! Inserting data with php script question
cunoodle2 replied to simpson_121919's topic in PHP Coding Help
Honestly the best thing to start with is a little code. What do you have so far? Here is a very very rough tutorial on how to do it.. <?php $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); mysql_query("INSERT INTO Persons (FirstName, LastName, Age) VALUES ('Peter', 'Griffin', '35')"); mysql_query("INSERT INTO Persons (FirstName, LastName, Age) VALUES ('Glenn', 'Quagmire', '33')"); mysql_close($con); ?> -
Are you getting an error message of any kind?
-
Please show your code where you are echoing and or working with your mysql query results.
-
You have a number of queries listed. Which one specifically are you looking to filter in between specific dates? Please narrow your selection so none of us has to read through 400 lines of code to find the specific issue. Based upon your recent activity on the board I need to once again mention.. Please be very very detailed in your response. What is happening? What do you actually expect to happen? Are you getting any error messages? If so what are they?
-
If you view source what you do you get? Also you ending the line after the "%;" Maybe try this... echo "div { width: ".$p."% }"; I know that the "%" is often use as the MOD math function. I'm wondering if that had something to do with it. Try out my code and let me know what happens.
-
That is not a view source. Here go to this page to see how to view source.. http://tinyurl.com/49xe89w Also I give up on trying to help. You can't follow basic directions.
-
I asked for a view>source. Do that and then we will move forward. My # questions could not have been any clearer. I'm not sure what the issue is here. The better info you give us the faster your question will be solved.....
-
I see that you have a lot of back and forths on many of your topics. Honestly posting something like the above of "nope, still is not working" does us/me ZERO good. Please do ALL of the following.. 1) Post your code. Without it we can't do ANYTHING 2) Also do a View > Source of your page and post that. Without that we can't do ANYTHING 3) Post any error messages you are getting. Without it we can't do ANYTHING Then answer these two questions.. 4) What are you EXPECTING to happen? 5) What is ACTUALLY happening?
-
On Form Submit - Check email for Duplicates
cunoodle2 replied to adriscoll's topic in PHP Coding Help
If you need to check for a particular event then you will need to add a WHERE clause to your query. I'm not sure of your table column names so I'm totally guessing here but it will likely be like... $sql_email_check = mysql_query("SELECT email FROM users WHERE email='$email' AND event_type='$event_name'"); -
((this MAY be the wrong forum but I'm not sure where this would go)).. I'm curious to see what program you guys do your actual programming in. I just started using Notepad++. It works pretty well. My issue with it is that it easily updates the remote file (on the webserver) but does not necessarily update the local file in all cases. Does anyone have any suggestions on a good php programming software to use?