-
Posts
3,145 -
Joined
-
Last visited
-
Days Won
37
Everything posted by cyberRobot
-
I would imagine that you would need to add an "else" component to the following: {if !empty($ad.img) && $ad.img != 'http://} <td valign="top" width="100"> <img src="{$ad.img}" style="max-height:100px; max-width:100px" /> </td> {/if} I'm not sure what that would look like since the above code isn't quite PHP. It's more like placeholder text that's converted into PHP.
-
Instead of adding the hash code to link, you could just add the user's login ID. You can then have the link lead to a script that looks up the ID and sends the hash code via email. The hash code never needs to be sent to the browser.
-
The more the merrier. Welcome!
-
fetured-image-grid in Wordpress-theme 2014 - the position
cyberRobot replied to dil_bert's topic in Third Party Scripts
It's been a while since I've experimented with Child Themes. But if I remember correctly and I didn't misread the quote below from the WordPress Codex, you'll need to completely replace whatever theme file you want to change. To change "page.php", you need to copy all the code from Twenty Fourteen's "page.php", paste it into your Child Theme's "page.php", and then make your changes. -
Well, I assume that the following line of code would display content on the screen without buffering the output: require_once PRIVATE_DIRECTORY . 'application' . DS . 'views' . DS . $file_name; Instead of displaying it directly to the screen, it looks like you want to assign the content to $body. If that's correct, you would use ob_get_contents(). Note that this function doesn't clear the buffer, so you'll need to also call ob_end_clean(). You could try changing this public function render($file_name) { if (preg_match("/\.html$/i", $file_name)) { ob_start(); extract($this->_variables); require_once PRIVATE_DIRECTORY . 'application' . DS . 'views' . DS . $file_name; $body = ob_flush(); } $this->_repsonse->append_body($body); } To this public function render($file_name) { if (preg_match("/\.html$/i", $file_name)) { ob_start(); extract($this->_variables); require_once PRIVATE_DIRECTORY . 'application' . DS . 'views' . DS . $file_name; $body = ob_get_contents(); ob_end_clean(); } $this->_repsonse->append_body($body); }
-
What do you mean by "sort this"? Is the program still not working? Or are you trying to change the sort order of something?
-
Yeah, you're right. That seems odd since ob_flush() isn't supposed to return anything.
-
Want to INSERT into one column that I have added
cyberRobot replied to rocky48's topic in MySQL Help
As far as I'm aware, the WHERE clause can't be used with INSERT. More information on the syntax can be found here: http://dev.mysql.com/doc/refman/5.6/en/insert.html Are you trying to update a set of existing rows? If so, have you looked into using UPDATE? https://dev.mysql.com/doc/refman/5.0/en/update.html -
Have you tried commenting out the output buffer block of code to verify that's what's causing the issue? For example, you could try something like this: public function render($file_name) { /* if (preg_match("/\.html$/i", $file_name)) { ob_start(); extract($this->_variables); require_once PRIVATE_DIRECTORY . 'application' . DS . 'views' . DS . $file_name; $body = ob_flush(); } */ $body = "<div>All good here ($file_name)</div>"; $this->_repsonse->append_body($body); } Perhaps the issue is caused by append_body()...
-
fetured-image-grid in Wordpress-theme 2014 - the position
cyberRobot replied to dil_bert's topic in Third Party Scripts
You could move the "featured-images". Just be aware that when the twentyfourteen theme is updated by the original developers, your changes will likely be lost...if you're editing the theme files directly. To avoid this issue, you could look into using Child Themes. More information can be found here: https://codex.wordpress.org/Child_Themes -
I haven't used jQuery with Ajax before, so this is just a guess. Have you tried commenting out the if test? }).done(function (data) { var result = data.status; //if (result === 'success'){ $('#ajaxDivAlert').fadeOut(); $('#ajaxDivOk').show().html('Informação: ' + data.message); $("#ajaxDivOk").fadeOut(5000); //} If the text appears in your <div> tag, you'll need to look closer at what data.status is returning.
-
Does your HTML page have a <meta> tag where the charset attribute is set to "utf-8"? More information can be found here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta If so, does your browser recognize the page encoding. For more information on how to check, see the following: http://htmlpurifier.org/docs/enduser-utf8.html#findcharset Is PHP set to use UTF-8? Note that you can use ini_set() and the "default_charset" configuration option to change the encoding a runtime. More information here: http://php.net/manual/en/function.ini-set.php Is the MySQL connection object set to use UTF-8? Note that you can use mysqli_set_charset() to change the encoding. More information can be found here: http://php.net/manual/en/mysqli.set-charset.php
-
Is your HTML page configured to be UTF-8? How about PHP? How about your MySQL connection? For what it's worth, the following article helped me make the switch to UTF-8: http://htmlpurifier.org/docs/enduser-utf8.html
-
It sounds like you pretty much have it covered with that pseudo code. Do you have a query that's not working? Perhaps the fourth example found in the following article will help: http://www.techonthenet.com/mysql/where.php
-
Sessions? How to secure pages for only logged in users
cyberRobot replied to FatesCall's topic in PHP Coding Help
Are you referring to the "Warning: session_start(): Cannot send session cache limiter - headers already sent..." warning? If so, session_start() needs to be called before outputting anything to the screen. Even a displaying white space before the call will trigger the warning. -
Have you tried using the WHERE clause? More information can be found here: https://dev.mysql.com/doc/refman/5.0/en/where-optimizations.html
-
Sessions? How to secure pages for only logged in users
cyberRobot replied to FatesCall's topic in PHP Coding Help
It looks like $pass is never set to "null"; so the following line should always equate to true: if ($pass != null) { You could try something like this: if ($user && $password) { foreach ($users as $key => $value) { if ($value == $password) { $pass = $key; //assign to session variable here, before you redirect, //assumes session started immediately after PHP open tag $_SESSION['user'] = $users[$pass]; echo "<div class=" . "success" . ">Successful. Redirecting you in 3 seconds.</div>"; echo "<meta http-equiv=" . "refresh" . " content=" . "3;URL=panel.php" . ">"; } } if (!isset($pass)) { echo "<div class=" . "warning" . ">Error: Username or Password is incorrect!</div>"; } } else { echo "<div class=" . "warning" . ">Error: Username or Password is incorrect!</div>"; } Note: session_start() needs to be called before anything is outputted to the screen. In other words, it needs to be called before the doctype tag. -
Sessions? How to secure pages for only logged in users
cyberRobot replied to FatesCall's topic in PHP Coding Help
Note that it may help to see your new code. What we assume is done doesn't always match with what was actually done. With that said, did you change the following lines: $user = "john doe"; $password = 1234; To something like this: $user = (isset($_POST['user'])) ? trim($_POST['user']) : ''; $password = (isset($_POST['password'])) ? trim($_POST['password']) : ''; If not, the code is always going to use the hard-coded values. -
For what it's worth, the link I provided earlier has a "Feature comparison" section for the three APIs (MySQL, PDO, and MySQLi). The main reason for switching is that the old MySQL API has been deprecated. And you'll want to be using one of the newer APIs before MySQL is removed from PHP. Of course, who knows when that's going to happen. But it's better to upgrade at your own pace then rush it when you are forced to switch. The other benefit of using PDO or MySQLi is that you can use Prepared Statements. A quick Google search should give you an idea of what those are.
-
You could use PDO or MySQL Improved (aka MySQLi). More information about choosing an API (and examples) can be found here: http://php.net/manual/en/mysqlinfo.api.choosing.php
-
Sessions? How to secure pages for only logged in users
cyberRobot replied to FatesCall's topic in PHP Coding Help
What does your code currently look like? Based on your original post, the script to process the form submission appeared to be embedded within the page that displays the form. However, the form submission is sent to "panel.php". So it seems like the form information would never get processed. -
Unless I'm missing something, $result contains the MySQLi result object. It looks like $data should contain the values you want.
-
Sessions? How to secure pages for only logged in users
cyberRobot replied to FatesCall's topic in PHP Coding Help
Don't worry; you're not alone. Note that I removed the duplicate posts. Perhaps the examples found here will help: http://php.net/manual/en/session.examples.basic.php Note that you can use $_SESSION variables just like you use $_POST and $_GET. You just need to make sure you call session_start() before using the variables. More information can be found here: http://php.net/manual/en/function.session-start.php -
For what it's worth, you can surround array variables with curly brackets if you want to include them in a string. echo "<p>{$data['value']} was checked</p>"; But I would use fastsol's suggestion for what you're currently trying to do.
-
Need help figuring out values that I need
cyberRobot replied to NalaTheFurious's topic in PHP Coding Help
Perhaps you've already done this, but you could search for "php pagination" on a search engine like Google.