karthik_ppts commented: Useful post +4
svilla 17 Junior Poster in Training
There is a comma before and after the WHERE clause. The last SET does not need a comma and ommma at the end will also cause an error. The last line of the SQL sould look like this
& "AdditionalInfo=@a34 WHERE (ID=@a35)", Con)
You are opening and closing the PHP tags quite a bit, This is not necessary for most of your code. The script is going to be processed from top of the file to bottom.
It appears that you are calculating the $total before you calculate the $carprice or $carcondition. In fact you are clearing $carprice right before you calculate the $total.
Also, since you obviously want $carprice to hold a number why are you clearing it with: $carprice = ''; instead of $carprice =0;? Syntacically PHP will allow this, but semantically you should initalize a variable with the data type it was meant to contain.
Clean up the first section and move it after the the last section.
// Take this section of code, clean it up and ....
<?php
if (in_array($zip1, $zipcoderadius) && in_array($zip2, $zipcoderadius)) {
$price = $fDistanceInMiles * .32;
$area = 0;
$total = $price + $area + $carcondition + $carprice;
} else {
$price = $fDistanceInMiles * .32;
$area = ($price / 10) * 3;
$total = $price + $area + $carcondition + $carprice;
}
?>
// ... move it after this section
<?php
if (isset($_POST['notrunning'])) {
$carcondition = ($price / 100) * 15;
}
?>
You can perform your own test inside the loop and use the break statement to break out of the loop.
I have been very successful removing Malware and virus with MalWareBytes. I have used this product to clean the laptops of students at the university I worked at. It is pretty thorough.
The software can be found at http://www.malwarebytes.org/. There is a free version which I have used exclusively and a version they sell with additional real time protection. As much as I have used it I probably should have purchased it, but for the most part I have used it on other folks computers.
Make sure that you are on the malware bytes site I listed above before you start the download since there are many malware products that will try to redirect away from this site. Te download link, will redirect you to TechSpot or majorgeeks to perform the actual download. Either site should be OK.
I have found that If I go to a clean machine and download the installer to a USB Drive and then install on the infected machine from the USB drive I have had greater success.
It will probably take several euns to completely remove all of the malware and you should boot into Safe mode for the first couple of runs. Once the complete scan comes back clean you are probably safe. If it finds any malware or viruses make sure you run it again until you have a clean scan.
Good Luck
In order to process PHP pages you need to run an HTTP server of some sort. It really does not have to be a separate PC as the browser acts like a client when connecting to the local HTTP Server via local host.
I also do not know why you need a separate server for running payment processing. You probably would want this in the real world, but for a proof of concept (like a thesis) you could also run this on the same PC.
I guess your configuration not only provides proof of concept but also that you are able to properly configure and address the connections between the servers.
As long as you are all on the same local network you should be able to connect the webserver. If you cannot connect, disable the firewall on the server for a moment and try again. This will tell you if you opened the wrong port, or if there is some additional security on the network.
You can always create your own cheapo network using a switch or router to eliminate the network as an issue.
ASP.NET is an application framework and one of the languages you can use in that framework is C#. So whatever restrictions are on ASP.NET are also on C#.
If you want to use a Linux server then you will not be able to use C# and ASP.NET (I may stand corrected after reading about Mono). But, for the most part, when working on a Linux Server you will be using PHP or JSP.
As previously stated the best language is based upon the application and your knowledge of that language.
Good Catch.
Usually when you get that error message that you listed there is an error with the Query. When mysql_query returns a boolean instead of a result set it has caught some sort of error.
Echo out the mysql_error and and mysql_errno, nonshatter's query should have worked.
You can also try to run the query in phpadmin or some other MySql interface just to make sure it is valid.
It would probably be easier if you declared a string and then moved it after the loop. I also declared a string variable so you don't have to mess with messageLabel and object notation inside the loop.
This will print all of the numbers between 0 and 10 (inclusive).
int counter = 0;
string str;
while (counter <= 10) {
str += counter.ToString() + ',';
counter++;
}
str.Remove(str.Length - 1, 1);
messageLabel.Text =str;
The Uppercase warnings look like the site was first built using the older HTML standards which allow upper and lower case in the tag names and attributes. Since moving over the it looks as if you are using the XHTML 1.0 standard which does not allow upper case in the tags.
<!-- Valid HTML Code, Not valid for XHTML --->
<H1>Heading</H1>
<DIV CLASS="class1">Inside Div 1 </DIV>
<!-- Valid XHTML Code --->
<h1>Heading</h1>
<div class="class1">Inside Div 1 </div>
Now these are only warnigs so your page should still show. But it is best to fix them and to adhere to the XHTML standards if that is what you are using.
The poster was creating a registration page and given the level of the question the most likely scenario is that there is a naming mismatch. Since the poster did not mention they were using AJAX it is highy unlikely that he is passing POST variables any other way.
By setting error_reporting(0); you are just masking the problem. If you are really interested in passing POST variables by some other method it would be best to test the POST array with the isset() function. This way the user has knowledge that the data is not coming from a form and can either allow or reject the request based upon that knowledge. Setting the error reporting off just opens the site to XSS attacks.
Never assume always test.
Check the name of your submit button it should match what you put inside the $_POST[] array. I would guess that you capitalized the name on the button or forgot it completely.
You should always have server side validation regardless of whether or not you use client side validation. There are so many ways to send bad data to a web page you always want to make sure that it is clean before you process it or use it in any database activities.
Client side validation is really a convienence to the user. The client will always provide quicker feedback to the user, you can notify the user as soon as they exit the field of an invalid entry. Using only server side validation requires the user to wait for there input to be validated on the server.
The difficulty is keeping these vaidation checks in sync.
htdocs is the default root for apache servers, inetpub is the default root for windows server. But it looks like a hosted site and public_html is where your files shold reside.
I do not see any issue with the resizing (of course I am using FF4.0) except that I am not a big fan of the resizing of the main content.
The pages look pretty much the same except for the container background and triangle under the selected menu option. The first issue is because sands.jpg does not exist on the second server. There could also be a missing image for you menu options.
There is a updatemode on the update panels that you can set to conditional. Here is a tutorial on how to use it:
http://www.asp.net/ajax/videos/how-do-i-use-the-conditional-updatemode-of-the-updatepanel
Ok, this takes a little bit more. You will have to create a PHP page between the order form and the process page. On this page you will need another form but instead of using text inputs use hidden fields and place the data you received into the value of the hidden fields. The Submit button on this confirm.php page will submit the data to the process page. The cancel button can just link to a dead page.
So...
The action on the order form will be confirm.php.
The action on the confirm page will be process.php.
Using the example I previously gave the hidden fields on the confirm page will look like this:
<input name="fname" type="hidden" value="<?php echo $_POST['fname'] ?>" />
Great.
You can mix PHP and HTML on the same page so in the process.php page you can just add all the html for the confirmation.
Just remember everything between the <?php ?> tags are interpretted as PHP. Everything outside is treated as html. So after the closing PHP code you can have all the regular html code. If you need to use the PHP $_POST variables in your html, just include them inside the <?php ?> tags.
<p>Thank you <?php echo $_POST['fname'] ?> for your order!</p>
Now you may see some folks use <?= $_POST ?> which is just a shortcut for the previous statement. The only issue is that the shortcut can be turned off in the php.ini file and if this page is every hosted on someone elses server the shortcut might not work.
Just so your instructor doesn't take off points make sure that the HTML you put in your PHP page has all of the required tags (<html>, <head>, <body>). I used to take off points when my students didn't have valid HTML or a <title>.
If you are asking a question at this level I doubt very seriously that your teacher wants you to delve into ajax calls. PHP is a server side language and javascript is a client side language.
In order to use PHP you have to have a web server with PHP installed. In simple terms, as the page is being retrieved, on the server, the PHP code is being processed. The web browser DOES NOT process PHP.
Javascript is processed by your browser. It is most often used to produce various effects and for form field validation. The web server DOES NOT process javascript.
For this assignment I bet the teacher is not really interested in the javascript but just the PHP code. The easiest way is to have two files. The first one is just an html page to present the form and the second a PHP page to process the request.
Make sure that you order form fields (in the html) are surrounded by the <form> tag. on the <form> tag set the action to the PHP processing page and the method to POST.
<form action="processOrder.php" method="post">
The name attribute on your <input> tags are automatically translated into $_POST variables. For example, if you had the following code:
<label for="fname">First Name</label>
<input name="fname" type="text" />
<input name="submit" type="submit" />
(It is the submit button that sends your form data to the page specified in the <form> tag's action attribute.)
The variable in your PHP …
You could save the primary key in hidden fields on the web form after the initial save. If the value of the primary key is null or blanks (which is an invalid value for a primary key) you know that the record needs to be inserted. If it contains a value, you know you need to update the record. This will also ensure that you have the primary key available for the Update process.
The nature of web pages should guarantee that if you navigate away from this page and then back to this page from another page that this will always be true (except, maybe, if they used the back button on the browser).
You could add an extra piece of mind by clearing the primary key field in teh page load when Not Page.IsPostBack.
It looks like you are not closing your second function properly.
function wordCheck($data, $fieldName) {
global $errorCount;
if (empty($data))
{
displayError($fieldName, "Please enter $fieldName");
$retval = "";
} else {
if (preg_match("/^[a-z]+$/i", $retval)==0)
{
displayError($fieldName, "Words must be letters only");
}
return($retval);
}
} // <======= Missing this closing Bracket
$words[] = wordCheck($_POST["lastname"], "lastname");
$words[] = wordCheck($_POST["forstname"], "firstname");
$words[] = wordCheck($_POST["address"], "address");
It appears that you put the closing bracket for the function all the way at the end of the code. Make sure you remove one of the closing brackets at the end of the code.
$wordnum = 0;
foreach ($words as $Word)
echo "Word ", ++$wordnum.": $Word<br />\n";
} } //<==== Remove one of these
Look into using an editor like Dreamweaver or Netbeans as they will help identify and highlight errors like these and maintain correctly indented code. When first starting out it is very difficult to spot errors, like this, if you don't adopt and maintain proper indentation. Actually, it is always difficult to follow improperly indented code.
Create a date data type.
Set it to the initial value.
Use in in while stmt incrementing the date with the DataArr function
NextDay = DateValue(DateStart.Text)
LastDay = DateValue(DateStop.Text)
While NextDay < LastDay
NextDay = DateAdd("d", 1, nextDay)
'
'
[I]' Your code to process each date[/I]
'
'
wend
make sure that you are filling the drop down box correctly it should look like this now:
while(list($name)=mysql_fetch_array($result)){
echo "<option value=\"$name\" >$name</option> \n" ; }
// or
while($row=mysql_fetch_array($result)){
echo "<option value=\"$row['state']\" >$row['state']</option> \n" ; }
Since your ID does not uniquely identify a state or a city but rather a user's comment you will have to change your thinking a bit. You should actually read about normalizing a database, but you could get away with the following code:
try
SELECT DISTINCT state FROM comments ORDER BY state
for you first drop down box.
I am the assuming that once the user selects a state you want to show a list of the cities in that state.
For the Second drop down you should then use:
SELECT DISTINCT city FROM comments WHERE state = '$state'
Once the user has selected the appropriate state and city you can then display a list of comments by using the following query
SELECT DISTINCT city FROM comments WHERE state = '$state' and city = '$city'
Your coding example is correct as long as the variable $memberid holds the correct ID number for the current user/member.
In my example the userID is the column name in the database, the $user is a php variable that holds the user/memeber's id.
I am not sure where you are holding the user information once the user has signed in, but in order to have access to this information on every page and eve subsequent requests to the same page you will have to put this information into session or cookie variables. Session variables might make the most sense.
<?php
session_start(); // required for session variables
$_SESSION['memberid'] = $memberid; // Perform after user has successfully logged in
$memberid = $_SESSION['memberid'] // Perform whenever you need access to Member ID
When you set up your SQL statement add a WHERE clause to restrict it to the current user.
let's say that the logged on user is in the $user variable. you would code it something like this.
$sql = 'SELECT * FROM data WHERE userID ='" . $user ."'"
You should probably substitute the field names you need for the *, but not knowing the layout of your data table this will retrieve everything from that table.
If you are using an MySQL database then you would want to execute the query like this:
//using mysqli functions
$result = mysqli_query($sql);
// using mysql functions
#result = mysql_query($sql);
You can find documentation and examples for mysqli functions here.
You can find documentation and examples for mysql functions here.
You need to make sure that the variable names match between what is on the URL and the $_GET variable. If you are passing dayArrive on the URL then you have to use $_GET to access it.
Yes. like this...
if (isset($_GET['dayArrive'])) {
// Process return variables
$dayArrive = $_GET["dayArrive"];
$month = $_GET["month"];
$year = $_GET["year"];
$nights = $_GET["nights"];
} else {
// First time processing (if any)
}
In order to access php variables They need to be inside <?php ?> tags.
Assuming that you have previously retrieved the correct row and that the $row now holds the data, you can use:
<a href = "mailto:<?php echo $row['sup_email']?>"></a>
PHP variables do not exist between pages you will either have to use session variables, cookies or URL vairiable to pass the information back.
The easiest might be to put the values into the URL. You would have to build your link for the return as follows:
$href = "AvailableRooms.php?dayArrive=" . $dayArrive . "&month=" . $month . "&year=". $year . "&nights=" . $nights;
Then change you link to be more like this
<a href="<?php echo $href ?>" target="_self" >Return to previous page</a>
This will create a link that looks like this.
<a href="AvailableRooms.php?daysArrive=15&month=5&year=2011&nights=6" target="_self" >Return to previous page</a>
Now the information is being passed back to the previous page correctly. You will have to also retrieve this information from the corresponding $_GET array just like you did with the post
$dayArrive = $_GET["dayArrive"];
$month = $_GET["month"];
$year = $_GET["year"];
$nights = $_GET["nights"];
You will also need to use isset($_GET["dayArrive"]) to test to see if you are getting data back or is this a first time display of the page.
You should look at the urlencode PHP function to make sure you do not have any issues passing information this way.
In phpmyadmin you have access to an text box where you can enter SQL just place the SQL code for your federated tables there.
Look for the tab that says SQL. I know my version has it (3.2.4)
Have you tried the .Net function ToUpper or ToLower? Here is the MSDN information on the function.
If you change the Apache configuration to look at *:80 instead of 192.168.1.56:80 then any incoming HTTP request, on port 80, will be processed by Apache.
So, if you are using the browser on the local machine, localhost or 127.0.0.1 will work. If you are trying to hit it remotely then 192.168.1.56 will work.