Jump to content

exeTrix

Members
  • Posts

    53
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    UK
  • Interests
    Devin' it up.
  • Age
    27

exeTrix's Achievements

Newbie

Newbie (1/5)

7

Reputation

  1. I've only used SOAP a handful of times. All I can say is, from my experience, it's bloated and annoying to make simple changes. I think JSON is the way forwar. Just bear in mind that most browsers block cross site requests returning JSON, so when sending JSON from other hosts JSONP is your friend. If you have code problems post them and we'll try and help
  2. Personally, I'd take that as they have to write their code which interacts with the functions they've defined. As Abra said it's terminology across languages. I have a colleague who uses the language cobol and he calls function sub-routines or procedure. I think it's only databases that make the distinction between procedures and functions.
  3. I've only had a quick glance but one thing that sticks out is on login.php. What's happening is you're not starting the session before you set session data, therefore, it's not getting stored. You're then redirecting the user within your class (site::login()) to index.php when session_start is invoked and obviously the check fails. So the first fix would be to move session_start to the very TOP of every page. There may be other issues but that's the first one you need to resolve. Nice to see people having a go at OOP by the way! Good job. Any problems then post back
  4. Because you have used single quotes. There are two solution to this problem and here they are (the first is a little more efficient): echo '<div class="form-warning">' . $message . '</div>'; //OR echo "<div class=\"form-warning\">{$message}</div>";
  5. If you have the validation in a different file then you could utilise sessions to set whatever data you wanted and redirect the user back to the form page. session_start(); //this need to be at the top of each page you're wishing to use sessions on $validationObject = (object) array( 'validationError' => false; ); $username = $_POST['username']; //run your validation here, I've done one as an example if (empty($username)) { $validationObject->validationError = true; $validationObject->username = (object) array( 'message' => 'User name is required', 'value' => $username ); //I know setting the value here seems like a waste of time but if you were validating an email then you'd want to return the attempt to the user } //before the logic for processing the form, here we're just checking for errors if ($validationObject->validationError) { $_SESSION['validation'] = $validationObject; header('Location: whateverPageYourFormIs.php'); die(); } //process the form //html starts here Then for your form page: <?php session_start(); if (isset($_SESSION['validation']) && $_SESSION['validation']->validationError) { $validationObject = $_SESSION['validation']; //unset the validation object so it's not used more than once unset($_SESSION['validation']); } ?> <!-- HTML header here --> <form method="POST" action="submit.php"> <fieldset> <label>Username</label> <div class="form-group"> <input name="username" class="span-default" type="text" placeholder="Choose a username" value="<?php echo (isset($validationObject, $validationObject->username)) ? $validationObject->username->value : ''; ?>"> <?php if (isset($validationObject, $validationObject->username)) { ?> <div class="form-warning"><?php echo $validationObject->username->message; ?></div> <?php } ?> </div> </fieldset> </form> I haven't tested this so it might have a few errors, but I'm sure it'll point you in the right direction. It's not complicated and uses stdClass objects. You could create a validation wrapper which may make things a little neater. Hope it help anyway, any problems then give us a shout
  6. That's not really a PHP question. This is probably what you'll want tho: <a href="/agent1.php" title="link title"><?php echo ucwords($agentdata[0]->cb_agentfirstname1.' '.$agentdata[0]->cb_lastnameagent1);?></a> Hope that helps
  7. No, the connection will be closed as part of garbage routine. This means resources are tied up until the end of execution... Not good.
  8. This should resolve the issue: mysql_select_db("", $con); $sql = "INSERT INTO apartments (username, title, county, town, type, description, cross_streets, phone, contact, office, pets, email, rooms, bath, square, rent, fees, service, space, feeornofee, lease, youtube, videotitle, imageurl1, imageurl2, imageurl3, imageurl4, imageurl5, imageurl6, imageurl7, imageurl8, imageurl9, imageurl10, imageurl11, imageurl12, date_created, lat, lng) VALUES ('".$myusername."', '".mysql_real_escape_string($_POST['title'])."', '".mysql_real_escape_string($_POST['county'])."', '".mysql_real_escape_string($_POST['town'])."', '".mysql_real_escape_string($_POST['type'])."', '".mysql_real_escape_string($_POST['description'])."', '".mysql_real_escape_string($_POST['cross_streets'])."', '".mysql_real_escape_string($_POST['phone'])."', '".mysql_real_escape_string($_POST['contact'])."', '".mysql_real_escape_string($_POST['office'])."', '".mysql_real_escape_string($_POST['pets'])."', '".mysql_real_escape_string($_POST['email'])."', '".$_POST[('rooms')]."', '".mysql_real_escape_string($_POST['bath'])."', '".mysql_real_escape_string($_POST['square'])."', '".mysql_real_escape_string($_POST['rent'])."', '".mysql_real_escape_string($_POST['fees'])."', '".mysql_real_escape_string($_POST['service'])."', '".mysql_real_escape_string($_POST['space'])."', '".mysql_real_escape_string($_POST['feeornofee'])."', '".mysql_real_escape_string($_POST['lease'])."', '".mysql_real_escape_string($_POST[('youtube')])."', '".mysql_real_escape_string($_POST[('videotitle')])."', '".mysql_real_escape_string($_POST['lat'])."', '".mysql_real_escape_string($_POST['lng'])."','".mysql_real_escape_string($images[1])."', '".mysql_real_escape_string($images[2])."', '".mysql_real_escape_string($images[3])."', '".mysql_real_escape_string($images[4])."', '".mysql_real_escape_string($images[5])."', '".mysql_real_escape_string($images[6])."', '".mysql_real_escape_string($images[7])."', '".mysql_real_escape_string($images[8])."', '".mysql_real_escape_string($images[9])."', '".mysql_real_escape_string($images[10])."', '".mysql_real_escape_string($images[11])."', '".mysql_real_escape_string($images[12])."', NOW(), " . (float) $lat . ", " . (float) $lng . ")"; Btw, make sure you haven't made the field unsigned in your database and given the firld enough decimal places for the long and lat to be stored correctly.
  9. I think that Smarty bridges the gap between developers and designers. It also facilitates the separation of business logic and template code because you'll usually have a PHP file and one or more views/templates. The latter of which can be achieved easily though using a modern framework, so in the second instance it'd probably be overkill to use it if that was the only benefit. Essentially, it's a template parser that allows the site builder (this can be a designer with only HTML knowledge) to add loops etc to pages without having to know PHP syntax. Just bear in mind, if you're planning on using Smarty there will be a substancial overhead involved as files are being parsed twice before output is generated.
  10. This is a Javascript question and I hate Javascript and along with jQuery library! Anyway, one solution is to return all your images from PHP in a json string then using interval switch the images based on the category. There is a rand work around which I've seen on StackOverflow items[Math.floor(Math.random()*items.length)] Then you'll be switching the images without polling PHP every nth interval. Just be carful with scope in JavaScript I'm not going to go into detail on that one because I'll be typing all night Good luck
  11. Basically, that is testing to see if the $variable has a value which is considered to have a value of true. However, this doesn't mean that the $variable can only have a boolean (true/false) value. The following values will NOT execute the code within the {} false - boolean 0 - int "0" - string 0.0 - float If I've missed any then I'm sure others will pitch in. I personally prefer empty() and will only use the code above if I know it can only be true or false.
  12. I don't like rand because it can produce the same result. If I'm creating a "random" file name I'll usually use something like this: $fileName = md5( time() . ' some crazy string just to keep the hackers on their toes ' ); echo $fileName . '.html';
  13. The regex won't work because you're using special characters as literals. This is purely from memory but you'll need to escape < and ! characters. Also, str_replace will accept arrays as parameters. So as long as you make sure they're in the correct order: $find = array( 'foo', 'bar' ); $replacements = array( 'Yo', 'Hoe'); $str = 'foo bar'; echo str_replace( $find, $replacements, $str ); //this is wrong btw str_replace('{$'.$word.'}', $itemrow[$word], $temporalpart); //needs to be this if you're going down that route str_replace($word, $itemrow[$word], $temporalpart); Hope that helps
  14. Try this: echo '<a href="' . $_SERVER['PHP_SELF'] . '?function=' . $i . '">Click here to call the function</a>'; What Jessica meant was you could do this: echo "<a href=\"{$_SERVER['PHP_SELF']}?function={$i}\">Click here to call the function</a>"; Double quotes will allow you to place variables in he string. However, the first method is quicker to parse
  15. I'm not seeing the point in the global phone number. You have the phone number set in session data ($_SESSION['phonenumber']). The only reason globals are pseudo useful is because variables can be used within class context without having to be passed in. If this phone number is a company number and will be constant then you'll be better off adding as below: define( 'COMPANY_PHONE', 0145875581144 ); echo COMPANY_PHONE; Sorry if I've misunderstood but you're doing the right thing moving away from globals.
×
×
  • 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.