Jump to content

trq

Staff Alumni
  • Posts

    30,999
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by trq

  1. C is indeed the correct answer.
  2. We are going to need to see your actual code.
  3. An update, I'm this thing to github. https://github.com/trq/proem/blob/route-dispatch/tests/lib/Proem/Controller/RouterTest.php
  4. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=320986.0
  5. Should be fine. Maybe your query is failing. Try... if (mysql_query("INSERT INTO posts SET to_id='$db_uid',from_id='$session',post='$db_post',type='$type',date='$db_date'")) { if (mysql_affected_rows()) { echo json_encode(array('msg' => 'success', 'postid' => mysql_insert_id())); } else { echo json_encode(array('msg' => 'failed')); } } success: function(html) { if (html.msg == 'success') { var post_id = html.postid; alert(post_id); } else { alert("Query failed"); } } You are actually issuing the alert within the success method? The variable 'post_id' will not exist outside of this method.
  6. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=320945.0
  7. Why would you limit the gallery to 200 images, and why would it take 200 fields to store 1 image? All you would really need to store are the path to the actual image, the alt , height and width attributes, a description and a few foreign keys relating the image to an owner, and gallery.
  8. It means that the version (of the extension) you have downloaded is not compatible with the php version that you have. I'm not sure what you can do except looking for a newer extension. These obscure extensions (ones that aren't installed via PECL) can be quite difficult to deal with unless your compiling & building them yourself. Sux to use Windows.
  9. Did you see the topic of this board?
  10. Remove the wildcards % from around $trimmed.
  11. Ive never had to use the no conflict option of jQuery (because I stick jQuery alone) but I think once you have done so, you need to refer to jQuery from then on in as jQuery and not $.
  12. You can either just simply echo it, or (better still as it allows multiple values to be returned and is handled negatively by js) use json. $id = $_POST['id']; //code that would run here for whatever //Then here is where I want to send a value back to the success of the ajax below echo json_encode(array('returned_val' => 'abc')); function post() { var id = get('id'); $.ajax({ type: "POST", url: "add_post.php", data: "id="+id, cache: false, dataType: 'json', success: function(html) { var variable_returned_from_php = html.returned_val; } }); }
  13. This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=320902.0
  14. Does the cronjob make a http request for the php script or execute if via php's cli? Have you tested it via php's cli? We'd need to see some code.
  15. This topic has been moved to Application Frameworks. http://www.phpfreaks.com/forums/index.php?topic=320893.0
  16. http://framework.zend.com/manual/en/zend.db.html
  17. Take a look at jQuery's 'live' method. http://api.jquery.com/live/
  18. So, redirect the user back to the form with a flag set that will trigger a pop-up. header("Location: http://yourdomain.com/form.php?m=template-exists"); If you need to repopulate the form with the data they have already submitted you would need to store that data in the $_SESSION array before redirecting, then retrieve it again on the form page. As for triggering the pop-up, that's a Javascript question.
  19. You didn't ask any question.
  20. I've not used Joomla, but I'm sure it uses an MVC architecture. $this likely refers to the View object. Generally what happens is templates are pulled into the View object before they are rendered, thus making $this refer to the object itself (the View). Now, what that View object is called and what file it's in I don't know, but that is where I would start.
  21. That would go where the.... // template already exists comment is.
  22. $query = "SELECT * FROM `templates` WHERE `templatename` = $templatename"; if ($result = mysqli_query ( $dbc, $query )) { if (!mysqli_num_rows($result)) { $query = " UPDATE `templates` SET `templatename` = '$templatename', `headercode`='".$headercode."', `footercode`='".$footercode."' WHERE `id` = '$templateID' "; if (mysqli_query($dbc,$query)) { if (mysqli_affected_rows($dbc)) { // update successful. } else { trigger_error("UPDATE Failed - $query - " . mysqli_error()); } } else { trigger_error("Update Failed - $query - " . mysqli_error()); } } else { // template already exists } } else { trigger_error("SELECT Failed - $query - " . mysqli_error()); }
  23. Please. Integers do not need quotes, and even if they did, that is poor syntax. $prodsql = " SELECT * FROM products WHERE id ='{$_GET['id']}'"; Complex variables (array & objects) should be surrounded by curly braces when within double quoted strings.
  24. I've just finished the initial development of my own Router component for my framework 'Proem' that you might want to take a look at. Nothing is documented as yet but looking at the tests should pretty much describe the functionality. http://codaset.com/trq/proem/source/route-dispatch/blob/tests/lib/Proem/Controller/RouterTest.php Basically, the Router can use many different types of Route objects, currently there are 3 implemented. Fixed - Directs every request to a specific controller and action, passes all other params untoched. Standard - Maps /controller/action/param1/value1/param2/value2, similar to your implementation. Then there is a 'Map' type Route. The Map Route allows you to map urls to named params very similar to how Zend's standard router works. See the above link for examples. The Map type is by far the most flexible and will likely get the most use, the other two where only built for speed and might come in handy on occasion. I haven't yet implemented any Dispatch yet, so all the Router does is return a Command object which contains all the controller, action and params data at present. It's all still very much a work in progress. Anyway, it might give you a few ideas.
×
×
  • 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.