-
Posts
3,145 -
Joined
-
Last visited
-
Days Won
37
Everything posted by cyberRobot
-
If you are using the deprecated mysql_* functions, you would use mysql_real_escape_string(): http://php.net/manual/en/function.mysql-real-escape-string.php Note that MySQLi and PDO also have functions for escaping strings. As for prepared queries, you could try a Google search for "php prepared statements".
-
While PDO is probably a better choice...you could also use MySQLi. More information about the two options can be found here: http://php.net/manual/en/mysqlinfo.api.choosing.php
-
Error in showing latest news or post in php
cyberRobot replied to mohitmohan's topic in PHP Coding Help
Good catch! What's with the shark attack link? @mohitmohan - You can find more information about PDO and MySQLi here (including non-shark-related examples ): http://php.net/manual/en/mysqlinfo.api.choosing.php -
function name must be a string? what function?
cyberRobot replied to dhmyers82's topic in PHP Coding Help
Try changing this echo '<img src="' . $zodiacPictures($imgCounter) . '"></img>'; To this echo '<img src="' . $zodiacPictures[$imgCounter] . '"></img>'; Note the square brackets around $imgCounter.- 4 replies
-
- 1
-
- fatal error
- function name
-
(and 1 more)
Tagged with:
-
Error in showing latest news or post in php
cyberRobot replied to mohitmohan's topic in PHP Coding Help
Did you check if the database query returned any results? Note that you can use mysql_num_rows() to find out: http://php.net/manual/en/function.mysql-num-rows.php If there are no rows, the stuff in your while loop won't get executed and the $title variable will never be defined. And in case you're not aware, the mysql_* functions have been deprecated. You'll want to switch to PDO or MySQLi in the near future. More information can be found here: http://php.net/manual/en/mysqlinfo.api.choosing.php -
...or PDO. More information about the different APIs can be found here: http://php.net/manual/en/mysqlinfo.api.choosing.php Based on the code originally posted, the resultset is being saved to the $rs variable. $rs = mysql_query('SELECT `pae_atividades`.`idativade` ... ORDER BY `pae_atividades`.`data` ASC '); $result contains something else.
-
Sorry about that...I didn't see the second error message in your original post. Did you check if MySQL is throwing any errors? More information about doing that can be found here: http://php.net/manual/en/function.mysql-error.php
-
Side note: the id attribute in your original code is used to connect the form label with the corresponding field. <label for="Name">Your Name</label> <input type="text" class="form-control" id="name" name="name" placeholder="Name"> Of course, the <label> tag wasn't successfully connected since the for attribute doesn't match the id attribute. One was set to "Name" and the other is set to "name"...note the case difference. With that said, you could just surround the input field with the label tag: <label>Your Name <input type="text" class="form-control" name="name" placeholder="Name"></label> More information about the <label> tag can be found here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label
-
Ah, it looks like you need to name the submit button also. Try changing this <input type="submit" value="Send">Send</button> To this <input type="submit" name="submit" value="Send"> The name attribute tells PHP to create the POST variable used here: if($_POST['submit']) {
-
The name of the GET variable is missing. Try changing this get_atividadesByUserId.php?=1261 To this get_atividadesByUserId.php?userid=1261
-
Do you get the error messages after the form submits? Note: to avoid seeing the errors before the form is submitted, move the initial variable declarations inside the construct that tests whether the form was submitted: <?php if ($_POST['submit']){ $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $from = 'From: Jarrod'; $to = 'email'; $subject = "Landing page"; $body = "From: $name\n Email: $email\n Message:\n $message"; if(mail ($to, $subject, $body, $from)) { echo '<p>Your message has been sent!</p>'; }else{ echo '<p>Something went wrong, go back!</p>'; } } ?>
-
You could use PHP's DOMDocument class: http://php.net/manual/en/class.domdocument.php It has an option to get elements by tag name: http://php.net/manual/en/domdocument.getelementsbytagname.php
-
Note that you can use phpinfo() to find out. More information can be found here: http://php.net/manual/en/function.phpinfo.php
- 4 replies
-
- php error
- syntax error
-
(and 1 more)
Tagged with:
-
The PHP file on your computer could be set up to send GET or POST variables to the online PHP page.
-
Have you looked into using local storage (HTML5)? More information can be found here: http://www.smashingmagazine.com/2010/10/11/local-storage-and-how-to-use-it/
-
Have you considered using something like Google Analytics to track link clicks?
-
For the update query, you could try something like the following example: http://www.tech-recipes.com/rx/2139/mysql_increment_an_exisitng_value/
-
From what I understand about the code so far, the hyperlink is fine as is. It just needs to direct visitors to the script which opens the movie. The script that opens the movie is where you would add the extra query to update the counter.
-
Edit Function doesn't pick the respective values
cyberRobot replied to helpmeout's topic in PHP Coding Help
Do you have PHP errors and warnings enabled...and being shown? Note that you can do that by adding the following to the top of your edit.php script: <?php error_reporting(E_ALL); ini_set('display_errors', 1); ?> Of course, you'll want to remove the above code once you are done debugging. Based on a cursory look through the code, it looks like $row is undefined in your edit.php script. -
Need help recognizing the type of php class etc..
cyberRobot replied to tommytx's topic in PHP Coding Help
Perhaps the following will help: http://php.net/manual/en/language.oop5.paamayim-nekudotayim.php It also looks like there is a WordPress function mixed in there: http://codex.wordpress.org/Function_Reference/wp_trim_words -
In the script which opens the movie, you just need to add a query which updates the database.
-
For what it's worth, here are a couple of resources to help with building forms: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms http://php.net/manual/en/tutorial.forms.php
-
In your movies.php file, are you trying to query DayMovie based on the selection made in the drop-down menu? If so, you'll need to use the corresponding $_POST (or $_GET if your form uses the GET method) variable instead of $key in the following line: WHERE FileDate LIKE '$key%'") Also, remember to protect your queries from SQL injection attacks by using something like mysql_real_escape_string(). http://php.net/manual/en/function.mysql-real-escape-string.php
-
Try moving the ORDER BY clause after the WHERE clause.
-
Do you know if the errors are being displayed? More information can be seen in example 1 here: http://php.net/manual/en/function.ini-set.php