-
Posts
3,145 -
Joined
-
Last visited
-
Days Won
37
Everything posted by cyberRobot
-
I was actually wondering about the code that defines get_url().
-
When using tags, this forum sometimes has issues with what comes after the box. However, the issue seems to go away if you preview the post before submitting it. To preview the post you can click the "More Reply Options" button.
-
I looks like get_url() is a user-defined function. What does the code look like? Does it expect multiple arguments or one long string?
-
I haven't looked too closely at the code, but I noticed that you're opening a PHP tag within PHP. Try changing this: <?php echo $user_data['group_id'] == GROUPS_ADMIN ? '<form method="post" action="<?php echo get_url(\'/products/\', $product[\'category_id\'], $product[\'product_id\'], $product[\'product_name\']); ?>?action=review">' : ''; ?> To this: <?php echo $user_data['group_id'] == GROUPS_ADMIN ? '<form method="post" action="' . get_url('/products/', $product['category_id'], $product['product_id'], $product['product_name']) . '?action=review">' : ''; ?>
-
Since you're expecting the ID to be a number, you can make sure it is with ctype_digit(): http://www.php.net/ctype-digit I wish they would update the documentation to include examples which don't involve connecting to the database. The error-checking function can be used after running any query. When debugging queries, you could try the following: $result = mysqli_query($con,$sql) or die(mysqli_error($con));
-
I honestly don't know; it seems like it should have.
-
Actually, the "endforeach" is probably supposed to be moved within the <select> tag. <?php foreach($data as $key => $value): echo '<option value="'.$key.'">'.$value['title'].'</option>'; echo "\r\n"; print_r(error_get_last()); endforeach; ?>
-
Is that your exact code? If so, the "endforeach" at the end needs to be surrounded by PHP tags. </body> </html> <?php endforeach; ?>
-
find/filter result between two strings more than once
cyberRobot replied to spaxi's topic in Regex Help
Have you considered using PHP's DOMDocument class? http://www.php.net//manual/en/class.domdocument.php -
Have you checked to see if MySQL is throwing errors? http://www.php.net//manual/en/mysqli.error.php
-
Note that you could merge activitySelectionChanged() and activitySelectionChanged2(): function activitySelectionChanged(elementID) { var activitySelect = document.getElementById('activity' + elementID); var selectedValue = activitySelect.value; var priceOutputBox = document.getElementById('activityPrice' + elementID); priceOutputBox.innerHTML = jsArray[selectedValue]["pris"]; } Then you would call the function with the following: <select name="activity" id="activity" onChange="activitySelectionChanged('')"> ... <select name="activity2" id="activity2" onChange="activitySelectionChanged(2)"> To answer your question, you'll need a span tag for the total: <tr> <td>Total:</td> <td></td> <td><span id="activityTotal"></span></td> </tr> Then in the function(s) which execute when a drop down menu changes, add something like the following: var price1 = document.getElementById('activityPrice').innerHTML; var price2 = document.getElementById('activityPrice2').innerHTML; var total = document.getElementById('activityTotal'); if(price1!='Pris' && price2!='Pris') { total.innerHTML = parseInt(price1) + parseInt(price2); } Note that the total will only be displayed when both fields are selected.
-
I'm not sure why the forum doesn't let you paste the code. But to add code tags, you can use the method describe by davidannis. Or you can type out the tags: your code goes here If the code tags are added properly, you should get a code box like the following: your code goes here
-
So you don't see any errors now? What happens if you replace this: $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); With this: $result = mysql_query ($query) or die("Query: $query\n<br />MySQL Error: " . mysql_error()); I have a feeling that a MySQL error is being thrown, but it's just being hidden since you're using trigger_error()...and your server is probably set to hide warnings and notices. Note that I'm not very familiar with trigger_error(), so I'm just guessing here. I think the problem comes from the query having back ticks (`) around the insert values. I'm fairly certain this: ... VALUES (`$nom`,`$prenom`,`$typecarte`, ... Needs to be this: ... VALUES ('$nom','$prenom','$typecarte', ...
-
No problem, hopefully it helps Side note: PHP now provides a built in function for validating email addresses. More information can be found here: http://www.php.net//manual/en/filter.examples.validation.php
-
Have you tried echoing the $errors array to see which error is being triggered? It should provide a clue to what's not working. For example, you could try something like this: echo '<p>Une erreur s´est produite lors de la soumission de votre paiment. Voulez vous bien réessayer ou cantacter notre service clientéle. Nous nous excusons d´avance.</p>'; echo '<pre>' . print_r($errors, true) . '</pre>';
-
When viewing the page in your browser, have you looked at the source code for the page? Does it look like the value for action attribute was interpreted correctly?
-
Variable passed to each() is not an array or object
cyberRobot replied to FUNKAM35's topic in PHP Coding Help
Note that you can see what type of variable $places is with var_dump(): http://www.php.net//manual/en/function.var-dump.php -
Are you getting any errors? If so, what are they? Note that using addslashes() will not protect you from SQL injections. You'll want to use something like mysql_real_escape_string(): http://www.php.net/mysql_real_escape_string
-
Based on a cursory look, the two scripts don't appear to be connected. It looks like you're trying to read in the database information in data1.php, then just redirecting to the script which displays the chart. Unfortunately, all the work done in the first script is lost when the redirect happens. If you're trying to use the database information in the chart, you'll need to merge the scripts.
-
Could you show the code you tried?
-
You could read the file into an array with file(): http://www.php.net/manual/en/function.file.php You can then loop through the array backwards...or reverse the array with array_reverse(): http://www.php.net/manual/en/function.array-reverse.php
-
Trouble Removing Certain Letters from Post Prior to Insert
cyberRobot replied to TecTao's topic in PHP Coding Help
If you post the code you tried, someone may be able to help fix it. Alternatively, have you looked into parse_url()? http://www.php.net/manual/en/function.parse-url.php Note that I personally haven't used the function before...and it may be overkill for what you're trying to do. -
Session id from another table to be entered in another table
cyberRobot replied to missanna08's topic in PHP Coding Help
Perhaps it's named something else. You could try echoing the SESSION variable to see what it contains: session_start(); echo '<pre>' . print_r($_SESSION, true) . '</pre>'; -
Changed php version now php scripts not working?
cyberRobot replied to rocky48's topic in PHP Coding Help
Are you able to switch back to 5.2? If so, I would recommend doing that. Then setting up some sort of development environment to prepare your scripts to 5.4. -
Session id from another table to be entered in another table
cyberRobot replied to missanna08's topic in PHP Coding Help
Have you checked to see if the ID variable contains a value? For example, you could try something like this: $empid = $_SESSION['empid']; var_dump($empid); Also, do you have PHP errors enabled? The following lines can be added to the top of your script to show all errors and warnings: <?php //REPORT ALL PHP ERRORS error_reporting(E_ALL); ini_set('display_errors', 1); ?> Of course, the above code should be removed once the issue is fixed.