-
Posts
3,145 -
Joined
-
Last visited
-
Days Won
37
Everything posted by cyberRobot
-
Does your real code have a query? As the code stands, $result is undefined. Have you tried turning on all PHP errors? To do that, you could add the following to your PHP script: <?php //REPORT ALL PHP ERRORS error_reporting(E_ALL); ini_set('display_errors', 1); ?>
-
Try changing this date('h:ia', strtotime($row['date_played'])) To this: date('g:ia', strtotime($row['date_played'])) Note that I changed the "h" to "g". More information about the date() function can be found here: http://php.net/manual/en/function.date.php
-
You could use strpos() to see if the string contains "abc" or "123": http://www.php.net/strpos
-
You're using an assignment operator (=) instead of the comparison operator for equals (==). More information can be found here: http://www.php.net/manual/en/language.operators.comparison.php
-
What do they use to make the background move?
cyberRobot replied to benoit1980's topic in Javascript Help
It looks like they are using the CSS "animation" property. More information can be found here: http://css-tricks.com/snippets/css/keyframe-animation-syntax/ To see the code used by Pinterest, you can right-click the background image in Chrome or Firefox and click "Inspect element". There should be a reference to "animation" or "webkit-animation" under the Styles/Rules panel. -
It might help if you provide a little more information. What do you mean by "it's not working"? Are you getting errors? If so, what are they? What have you tried to debug the issue? For example, have you checked if the database query returned anything? Have you enabled errors? Note that you can add the following snippet to the top of your script to show all PHP errors and warnings: <?php error_reporting(E_ALL); ini_set('display_errors', 1); ?>
-
When the var_dump() code was added, did you check the box and submit the form? Something should have been displayed. Is there a reason you have two form fields with the same name? Have you tried removing the hidden field to see if that's what's causing the issue? If you're trying to make sure that "møtt" always has a value, you could employ Barand's suggestion. $møtt = isset($_POST['møtt'] ? $_POST['møtt'] : 0;
-
Have you looked to see what the checkbox value contains? Try using var_dump() after you read in the POST variable for "møtt": $møtt=$_POST['møtt']; var_dump($møtt); You might also need to check the source code (when viewing the page in your browser) for the form to see if the checkbox is being assigned the proper value.
-
Since your form hasn't been submitted, the POST variables for "registrerMottKnapp" doesn't exist yet. To fix the error, you need to change this: $registrerMottKnapp=$_POST ["registrerMottKnapp"]; To something like this: $registrerMottKnapp = (isset($_POST['registrerMottKnapp'])) ? $_POST['registrerMottKnapp'] : false; Personally, I would eliminate the extra variable ($registrerMottKnapp) and just do this: /* include("valider-mott.php");*/ if (isset($_POST['registrerMottKnapp'])) {
-
Have you tried modifying your PHP script to show all errors and warnings? To do that, you could add the following lines of code to the top of your script: <?php error_reporting(E_ALL); ini_set('display_errors', 1); ?> You could also see if MySQL is throwing errors by using mysql_error() after each query. http://www.php.net/manual/en/function.mysql-error.php
-
p:first-child:first-letter not working in wordpress
cyberRobot replied to Crispylogs's topic in CSS Help
It looks like the first paragraph tag within the "entry" div tag on your page contains an image. If this paragraph tag contained text, the effect should work. -
Your checkbox name has a lower case "m": print("<input type='checkbox' name='møtt' value='$møtt'>"); But the code which processes the form submission uses and upper case "M": $møtt=$_POST["Møtt"];
-
Script not working and can't understand error
cyberRobot replied to Phaelon's topic in Javascript Help
It looks like you're mixing up PHP and JavaScript. Here are a couple things that I noticed: JavaScript variables don't use the dollar sign. More information can be found here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals The concatenation character for JavaScript is "+". More information can be found here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#String_operators -
Issues with Getting data from DB and Saving it back
cyberRobot replied to dapcigar's topic in PHP Coding Help
Have you considered modifying you database? The script could keep saving the category ID to the database. You could then modify the scripts which utilize the "requisition" database table so they use a JOIN query to get the category name based on the ID. http://www.techonthenet.com/mysql/joins.php -
Issues with Getting data from DB and Saving it back
cyberRobot replied to dapcigar's topic in PHP Coding Help
In the code which processes the form submission, you could add another query to get the category name based on the passed ID. Note that you'll want to make sure the ID is a number before running the query to prevent SQL injections. You could use ctype_digit() to check for numbers: http://www.php.net/manual/en/function.ctype-digit.php Alternatively, the form could be modified to pass the category name: <option value="<?php echo $cat_name;?>"><?php echo $cat_name; ?></option> Side note: perhaps you're already aware of this, but form information can be tampered with by the user. To prevent SQL injections, you can utilize mysql_real_escape_string(): http://www.php.net/mysql_real_escape_string -
I've been using a service called amCharts (http://www.amcharts.com/) which works fairly well. Note that I haven't spent much time with any other chart solution, so I can't speak to the pros/cons of the various services. If you want to avoid using third-party services and you're looking to create a bar graph, I wrote a post a while back which talks about a solution I've used in the past here: http://www.cyberscorpion.com/2012-08/simple-bar-graphs-made-dynamic-with-php/
-
Error mysql_num_rows() expects parameter 1 to be resource
cyberRobot replied to merpati's topic in PHP Coding Help
Strings can have either single or double quotes around them. However, double quotes are needed if the string contains something PHP needs to expand like a variable. More information about strings can be found here: http://www.php.net/manual/en/language.types.string.php I may have missed it, but I don't see where the OP (merpati) is using MySQLi. They all look to be regular MySQL functions. Of course, the OP should consider using something other than mysql_* functions since they are deprecated (http://www.php.net/manual/en/mysqlinfo.api.choosing.php). He/she may already be looking into that though. That's a good point. I would imagine that's supposed to be $run. @merpati - have you tried using mysql_error() to see if there are any SQL errors being reported? More information can be found here: http://www.php.net/manual/en/function.mysql-error.php -
Note that is_numeric() will consider the follow as numbers: 0x539 1337e0 9.1 To make sure the values only contain numbers, you can use ctype_digit(). http://www.php.net/manual/en/function.ctype-digit.php Also, it's worth pointing out that richei added a call to mysql_error() to the following line: $ins = mysql_query("INSERT INTO CodigoF (NOMBRE,PW) VALUES ($nombre, $pw)") or die(mysql_error()); This function should help determine if there's anything wrong with the query. More information about the function can be found here: http://www.php.net/manual/en/function.mysql-error.php
-
Get only first element of array from SQL fetch array
cyberRobot replied to imprint's topic in PHP Coding Help
I've been there. I tend to go straight to PHP for solutions. I've been learning, however, that MySQL has a lot to offer. -
Reflecting Database Info on the Members Page
cyberRobot replied to gordonp's topic in PHP Coding Help
No problem, the comment was more directed at gordonp. It kind of sounds like he/she is just starting out with database programming and it's easier to make the switch now vs down the road. -
Reflecting Database Info on the Members Page
cyberRobot replied to gordonp's topic in PHP Coding Help
Just in case you're not aware, the mysql_* functions have been deprecated. You'll be better off switching to MySQLi or PDO. More information can be found here: http://www.php.net/manual/en/mysqlinfo.api.choosing.php -
Get only first element of array from SQL fetch array
cyberRobot replied to imprint's topic in PHP Coding Help
Are you able to adjust the query so it only fetches one result? You could do this with the LIMIT clause. https://www.google.com/search?q=sql+limit -
Assuming that visitors can check more than one "interest" box, you could process the selected values like this: if(isset($_POST['interest']) && is_array($_POST['interest'])) { foreach($_POST['interest'] as $currInterest) { echo "<div>$currInterest</div>"; } } Of course, you'll need to adapt the code to fit your needs. Note that I added an is_array() test to make sure the "interest" variable is an array before using the foreach loop. That way you don't get errors if the user decides to tamper with the data submitted.
-
Note that the above code will give an undefined variable notice if you show all errors. Instead, you could use something like this: if(isset($_POST['interest'])) { //process the "interest" values here } When the POST variable is set, it should be an array as long as the corresponding checkboxes are named appropriately.
-
You could store the image information in an array and then use array_rand() to get a random selection: http://www.php.net/manual/en/function.array-rand.php