Jump to content

Cep

Members
  • Posts

    539
  • Joined

  • Last visited

    Never

Everything posted by Cep

  1. Shouldn't it be <?php else if (($_SESSION['usertype'] == "1") && ($logged == "true")) ?> However as your evaluating true for your $logged var you don't need quotes if its a bool type.
  2. Ah no, as discomatt says if another value is written into the textbox the default will be ignored so you can safely use the attribute value="worker" for a default value.
  3. Ok I'll give you a breakdown. For loops are controlled by the 3 expressions you see. $i = 1; // first expression $i<=5; // second expression $i++; // third expression First your saying that the control variable $i will start at the value 1. It could start at any value you like, in fact it could be any variable you like too such as $x or $zebidee as long as its value is one you can control with the other two expressions. This as you guessed is the initialisation expression. The second expression, $i <= 5; means that the loop must only loop if the value of $i is less than or equal to 5. This condition expression can also be different to what we see here, it could be $i < 2; which would cause our current loop to loop only once because $i = 1, and therefore $i must be less then 2, (1 or 0) so loop once. The third and final part basically says, take the value of $i and now add 1 to it. Or $i = $i + 1; The loop will then fire and go back to the condition statement. It will ignore the initialisation statement because $i already exists. $i is now 2 because we incremented it on that previous loop using $i++; It will then re-evaluate the value against the condition so is 2 less than or equal to 5? The answer is yes, so move onto the increment statement $i++ ($i = $i + 1 or 3 = 2 + 1) The loop will fire again and keep re-evaluating until finally the condition fails (when $i is no longer less than or equal to 5, when it becomes 6) at which point it will exit the loop.
  4. Your not loading off a cookie somewhere else in your script are you?
  5. Yes the API should enable you to interact with their payment gateway no matter what type of shopping cart you set up.
  6. If your setting a default value for a specific set of data (one the user cannot customise) you really want to use a drop down menu instead. If your users can customise the data in the field then you would only need to check for a blank or null value and then use an if statement like this, <?php if ($_POST['myvalue']==="") { $myvalue = "worker"; } ?> Of course you would have first validated the post variable before reaching this point.
  7. I believe this is done using the web services API from Google. You funnily enough may want to Google, Google for the information
  8. Of course its going to echo LOL that is still the value of your session index which you set on line 1. What your next two lines have done, will not affect the echo statement at the end because that's not what your echoing.
  9. Its ok, I just realised I am not following the correct standard for the feed tags!
  10. And what happens when the data in sub category table changes? This will not update the users array and therefore would cause problems. AJAX is the only way to do this properly.
  11. Cep

    mkdir?

    if mkdir() is returning failed its most likely because you do not have permission to create folders. What is the permission level of the parent or root directory? Does it allow anonymous creations of directories (I doubt it).
  12. Hi, I know I am doing something stupid here but for the life of me I cannot see what. This code should read a local database on my webserver and then output an RSS feed based on the information. The RSS feed is basically a string variable made of up the database information. However two fields in my database can have illegal characters like ampersands which will break the xml so, my plan is to CDATA these sections. The only problem is using CDATA seems to cause the PHP parser to screw up I know I am doing something wrong but I just can't quite put my finger on it. Here is my script, <?php function db() { $user = ""; $pass = ""; $database = "dave_rss"; $db_conn = odbc_connect($database, $user, $pass) or die ("Unable to connect".odbc_errormsg()); return $db_conn; } function odbc_record_count($result, $db, $query) { $num_records = odbc_num_rows($result); if ($num_records < 0) { $count_query_string = "SELECT count(*) as results FROM ({$query})"; $count = odbc_exec($db, $count_query_string); $num_records = odbc_result($count, "results"); } return $num_records; } $thisyear = date('Y'); $sql = "SELECT * FROM qryRssFeedCourses"; $xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n"; $xml .= "<rss version='2.0'>\n"; $xml .= "<channel>\n"; $xml .= "<title>mypeeps</title>\n"; $xml .= "<description>A list of our up an coming courses at mypeeps.</description>\n"; $xml .= "<link>http://www.mypeeps.com/</link>\n"; $xml .= "<copyright>mypeeps copyright {$thisyear}</copyright>\n"; $xml .= "<image>\n"; $xml .= "<title>My Peeps</title>\n"; $xml .= "<link>http://www.mypeeps.com/</link>\n"; $xml .= "<url>http://mypeeps/rss/moomin.gif</url>\n"; $xml .= "</image>\n"; $result = odbc_exec(db(), $sql) or die ("Unable to run select query ".odbc_errormsg()); $num_rows = odbc_record_count($result, db(), $sql); for ($i = 1; $i <= $num_rows; $i++) { $row = odbc_fetch_array(odbc_exec(db(), $sql), $i) or die ("Unable to fetch row"); $date = date("D M Y", strtotime($row['From Date'])); $title = "<!CDATA"."[{$row['Title']}"."]]>"; $venue = "<!CDATA"."[{$row['Name of Location']}"."]]>"; $xml .= "<item>\n"; $xml .= "<title>{$title}</title>\n"; $xml .= "<venue>{$venue}</venue>\n"; $xml .= "<level>{$row['Course Level']}</level>\n"; $xml .= "<type>{$row['CourseType']}</type>\n"; $xml .= "<speaker>{$row['Speaker']}</speaker>\n"; $xml .= "<times>{$row['From Time']} to {$row['To Time']}</times>\n"; $xml .= "<date>{$date}</date>\n"; $xml .= "</item>\n"; } $xml .= "</channel>\n"; $xml .= "</rss>"; echo $xml; ?>
  13. Its fairly simple, I won't give it all away though <?php $tbl = "<table><tr>"; $mydata = array('A', 'B', 'C'); foreach ($mydata as $data) { $tbl .= "<td>{$data}</td>"; } $tbl .= "</tr></table>"; echo $tbl; ?> You don't have to use an array, this could be a row call to a database and a completly different loop but you get the idea?
  14. How would Javascript know what the new items were unless you planned to type them all into your Javascript file/tags? It would more likely come from a database source, which will require a request to the server, which will be an AJAX method.
  15. I would build a string to do this and then concatenate each cell in a loop.
  16. If you are using Javascript events your going to need to use an AJAX method.
  17. Cep

    mkdir?

    I would test to see if mkdir is creating the folder. As mkdir will return a result you can do this, <?php $success = mkdir($mkdir); if ($success===true) { echo "Directory succeeded"; } else{ echo "Directory failed"; } ?> By the way you do not need to surround the variable $mkdir in quotes.
  18. FTP a browser would constantly time out.
  19. You know what keeB I never saw that when I went through the manual. However isn't there issues with using persistent connections? I'm rather new to OOP so I am still getting my head around it but from what I gather I should be able to pass a database connection object to another objects properties and then serialise the object with sessions. This doesnt appear to work though, so I have had to create an include for my database connection in the __wakeup method in case the database property becomes vacant.
  20. What scales are you using? I am going to hazard the guess that this is something to do with the maths involved. Heres an example of your if statement for a landscape (300h x 500w) 1.8 = 900 / 500 900 = 500 * 1.8 540 = 300 * 1.8 300h x 500w becomes 540h x 900w This seems fine but now check your portrait values for the same type of image size (500h x 300w) 3 = 900 / 300 1500 = 500 * 3 900 = 300* 3 Your new values are going to be huge in comparison, 500h x 300w becomes 1500h x 900w Perhaps and this again is a guess, your script has a restriction on the image size?
  21. I have re-written your function because the version you have would not work (look at your if statement). Try it, I cannot test the functionality unfortunately my IIS does not support the image functions. <?php function resizeImage($orientation, $target) { // Get the original geometry and calculate scales list($width, $height) = getimagesize($target); $scaler= 900; if ($orientation==="landscape") { $scale = $scaler / $width; $new_width = round(($width * $scale)); $new_height = round(($height * $scale)); } else { $scale = $scaler / $height; $new_width = round(($width * $scale)); $new_height = round(($height * $scale)); } // Resize the original image $imageResized = imagecreatetruecolor($new_width, $new_height); $imageTmp = imagecreatefromjpeg($target); imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $new_width, $new_height, $width, $height); return $imageResized; } ?>
  22. You could just use an include too
  23. You may want to consider not using the docblock for the GNU GPL part of your script and using a standard comment block instead. Other then that this place should help you http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.pkg.html
  24. If you are submitting a form, pressing back will result in a warning about re-posting data back to the server. What you should be doing rather then encouraging users to use the "back" button is to redirect them back to the page automatically after whatever process you have done with the submitted form data. To redirect you would need to use header() function.
×
×
  • 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.