-
Posts
3,145 -
Joined
-
Last visited
-
Days Won
37
Everything posted by cyberRobot
-
Help outputting data from mySQL Database using PHP for a website
cyberRobot replied to louiscb's topic in PHP Coding Help
With each iteration of the loop, the variables will be overwritten. To display all the results, you could output the information within the while loop. Perhaps the following example will help: http://www.tizag.com/mysqlTutorial/mysqlfetcharray.php -
Are you looking for help with building the quiz...or randomizing the questions? If it's the latter, you could try one of the tutorials found here: https://www.google.com/search?q=php+randomize+quiz+questions
-
The error means the $delete hasn't been set yet. You could use isset() to test the variable: http://php.net/manual/en/function.isset.php Also, since it looks like that variable is supposed to come from an HTML form, you may want to check out the PHP manual for $_POST and $_GET.
- 1 reply
-
- php
- undefined variable
-
(and 1 more)
Tagged with:
-
Perhaps one of the following articles will help: https://www.google.com/#q=css%20input%20border%20shadow
-
You could do something like this: input { border:0; border-bottom:1px solid #666; }
-
You could use CSS to hide the border of the form field. Then place a border beneath content element that holds the field and label. Note that the search box on the CSS Tricks website (http://css-tricks.com/) is styled that way. You could dig through the source code to see how it's done.
-
Passing form data to multiple scripts
cyberRobot replied to redqueentoknightfour's topic in PHP Coding Help
You could pass them using hidden form fields. https://www.google.com/#q=html%20hidden%20field -
Guys I need Help some need to Combine Checkbox and Textbox Value
cyberRobot replied to sohailsaif's topic in PHP Coding Help
"Array" is coming from this line: foreach($tc=$_POST['tld'] as $value){ Since $_POST['tld'] is an array of checkbox values, $tc becomes "Array". To get the string, you just need to take the suggestion by davidannis and assign it to a variable. For example: $selections = array(); foreach($_POST['tld'] as $value){ $selections[] = $_POST['domain'].$value; } echo implode('<br>', $selections); -
Is there a particular line of code that I can help explain? The most foreign part is probably this: $bgcolor = ($count % 2) ? '' : ' bgcolor="#F8F8F8"'; This line uses the ternary operator to keep the code short. You could re-write it as: if($count % 2) { $bgcolor = ''; } else { $bgcolor = ' bgcolor="#F8F8F8"'; } More information about the ternary operator can be found here: http://php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary To calculate the row color, I just used the modulus operator which is discussed here: http://php.net/manual/en/language.operators.arithmetic.php#70424
-
Guys I need Help some need to Combine Checkbox and Textbox Value
cyberRobot replied to sohailsaif's topic in PHP Coding Help
In case it helps, the following tutorial shows the basics on working with forms: http://php.net/manual/en/tutorial.forms.php -
Also note that the code could be simplified a bit. The following is untested: <?php //INITIALIZE COUNT $count = 0; while($row = mysqli_fetch_assoc($retval)) { $cardname = $row['Name']; $encodedcardname = str_replace(" ","%20",trim($cardname)); $url = "http://mtgimage.com/card/$encodedcardname.jpg"; //GET ROW COLOR $bgcolor = ($count % 2) ? '' : ' bgcolor="#F8F8F8"'; //DISPLAY CURRENT ROW echo '<tr' . $bgcolor . '><td>'; echo "<a href=$url>$cardname</a>"; echo "</td><td>"; echo $row['Color']; echo "</td><td>"; echo $row['Type']; echo "</td><td>"; echo $row['Subtype']; echo "</td><td>"; echo $row['Power']; echo "</td><td>"; echo $row['Toughness']; echo "</td><td>"; echo $row['Manacost']; echo "</td><td>"; echo $row['Rarity']; echo "</td><td>"; echo $row['Expansion']; echo "</td><td>"; echo $row['Foil']; echo "</td><td>"; echo $row['Stock']; echo "</td></tr>"; //INCREMENT COUNT $count++; } echo "</table>"; ?>
-
The "duplicates" are likely caused by $cardname (and the other variables) only being updated when $color == 1. Try moving the variables below before the if statement: if($color==1){ $cardname = $row['Name']; $encodedcardname = str_replace(" ","%20",trim($cardname)); $url = "http://mtgimage.com/card/$encodedcardname.jpg"; //...
-
So basically, you want the checkbox to reflect whatever is in the database? If so, you just need to read in the checkbox value from the database prior to displaying the form. Then assign whatever the database contains to $r['obcDisplay'] and display the form. If a value isn't found in the database, you can set $r['obcDisplay'] to whatever you want the default to be.
-
That doesn't necessarily mean the OP isn't looking for options. Perhaps AdamHull12 is just using "Secure" in a general sense...or maybe doesn't realize there is a difference between validating, filtering, escaping, etc.
-
@AdamHull12 - It might help to know more about what you're trying to do. Are you working on a form and trying to validate the input? If so, you could run $id through ctype_digit() to make sure it's a number...assuming that's what you expect. If $id turns out to be something else, you could re-display the form and show an error.
-
In addition to the suggestions provided already, there are more options available in the manual: http://php.net/manual/en/functions.arguments.php
-
Side note: Using the raw value from PHP_SELF in the form's action attribute opens your website up to XSS attacks. To have the form submit to the same page, you can leave the action attribute blank. <form method="post" id="myform" action="">
-
Which database API are you using...MySQL, MySQLi, PDO? Each of these APIs have a way to escape the string for you. MySQL, for example, uses mysql_real_escape_string(): http://php.net/manual/en/function.mysql-real-escape-string.php MySQLi also has a function for escaping strings called mysqli_real_escape_string(). If you are using MySQLi or PDO, you can also use Prepared Statements. Side note: urlencode() isn't meant to escape strings for database use. It is meant to prepare a string to be used in a URL. More information can be found here: http://php.net/manual/en/function.urlencode.php
-
Since the single quote appears in the middle of a singled-quoted string, you need to escape the value. How is the query being built? For what it's worth, more information about escaping values in strings can be found here: http://dev.mysql.com/doc/refman/5.0/en/string-literals.html
-
get sum of two variables using javascript not working
cyberRobot replied to candid's topic in Javascript Help
The code works for me after changing this: var total_extra =<?php echo $price_per_day; ?> To this: var total_extra =<?php echo $price_per_day; ?>; Note the semi-colon at the end. -
@bravo14 - You're probably already aware of this, but you can validate your HTML here: http://validator.w3.org/ The W3C also has a CSS validation tool here: http://jigsaw.w3.org/css-validator/ As for your question, the code seems to work for me in Internet Explorer, Firefox, and Chrome. Perhaps the background image URL isn't pointing to the right address. Is your CSS in an external file...or is it in your HTML document? If it's in an external file, perhaps the issue is caused by the document-relative path. You could try switching to a root-relative path. More information about the different path types can be found here: http://brugbart.com/paths
-
Just in case it was missed, have you tried processing the query results as suggested in post #5? See the part about using mysqli_fetch_assoc(): http://forums.phpfreaks.com/topic/291471-php-where-clause/?do=findComment&comment=1492871
-
What kind of errors are you seeing? Note that it will help to see the exact messages. Side note: In case you're not aware, PHP has a built-in function for validating email addresses here: http://php.net/manual/en/filter.examples.validation.php
-
Just to clarify my post, you are currently echoing the variable created here: $listingtitle=$_POST['listingtitle']; Which is why I suggested changing your echo statement. However, it looks like you're trying to get the "listingtitle" using the following query: $query = mysqli_query($con,"SELECT listingtitle FROM privatelistings WHERE item LIKE '%$submittedby%'"); For that to work, you need to process the query results with something like mysqli_fetch_assoc(). More information can be found here: http://php.net/manual/en/mysqli-result.fetch-assoc.php
-
Try changing this: echo "<p>Title: {$listingtitle['listingtitle']}</p>"; To this: echo "<p>Title: $listingtitle</p>";