Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. That line can be easily fixed using <?php if (isset($error) && !empty($error) { As for the undefined id index. it appears your form is not submitting the id field on form submission. the $id variable appears to be passed to the renderForm() function as a parameter function renderForm($bedrijfsnaam ='', $factuurbedrag ='', $vervaldatum ='', $voldaan ='', $opmerkingen ='', $id ='') The code for this function will only set the id form field if the $id variable is not emtpy. <?php if ($id != '') { ?> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <p>ID: <?php echo $id; ?></p> <?php } ?> The format of the HTML is correct for the id form field. Where is the function renderForm() called from and how is $id set?
  2. Errors should be displayed on the page you're viewing. You may beed to enable display_errors // Report all PHP errors display_errors(true); error_reporting(E_ALL);
  3. How long have you had this script? Did you write it yourself? I'm not surprised you have been compromised. It is using old out dated code. The first thing I noticed is there is hardly any validation/sanitation of user input, unless this happening somewhere else. Imo, this script will require a complete re-write. If you can't do this yourself then you're better of hiring someone to do this for you. However looking at the code I expect this is from some form of third party CMS. You're better of seeing if there is an updated version or converting your site to some other third party CMS like wordpress, joomla which more up to date.
  4. You could use date('g'); to get current hour no?
  5. he, no problem glad to help
  6. Have a look at the example code @ http://www.phpro.org/examples/Parse-HTML-With-PHP-And-DOM.html Play around with that. Read the documentation for using DOM ( .josh probided a link earlier). You should be able to get lang attribute for the html tag in just a few lines of code. All it takes is for you sit down read documentation testing/playing with examples and then you should be able to implement this yourself.
  7. You are going to http://localhost/ to run your php scripts. You can't directly access php scripts from file:// protocol. Those errors are coming from a browser extension you have installed called flashblock. This could be interfering, try disabling it. Any way ou may also want to read this part of the documentation https://code.google.com/p/swfobject/wiki/documentation#STEP_3:_Embed_your_SWF_with (I assume that is the js library you're using) The id (secound) parameter for swfobject needs to be the name of the html element where you want the swf file to be displayed. Having just that line of javascript isn't going to display the swf file. You may need to add this line to your while loop echo '<div id="'.$id.'"><p>Alternative content</p></div>';
  8. Ok so your code PHP is working correctly as it a is outputting the Javascript code within your while loop. The next problem to tackle then is making sure your Javasript does not have any errors If you are using the latest version of IE, Firefox, Chrome etc you should to access the Developer Tools pain by pressing F12. Go to the console tab and refresh your page (using F5). Does the console log any errors?
  9. My bad the code I gave you had an error. It should be $result = mysql_query("SELECT * FROM games") or die('Query Error: '. mysql_error());
  10. That error usually indicates your query is failing due to an error or is returning an empty result. To see if there is an error from your query. Chang the mysql_query line to $result = mysql_query("SELECT * FROM games") or die('Query Error: ', mysql_error()); This should print out an error if the query is failing.
  11. Ok sounds like PHP is failing due to an error. Add the following two lines before require_once('config.php'); error_reporting(E_ALL); ini_set('display_errors', true); What errors are shown?
  12. your code for getting the path out of the database looks fine to me. What is the following line outputting? echo "swfobject.embedSWF('$path','$id', '$width', '$height', '$version')";echo "</script>"; Is this outputting the correct JavaScript syntax? if it is you need to make sure $path is pointing to correct location of where your .swf files are located.
  13. PHP cannot find the variable $mysqli. I assume this is defined in db_config.php Are you sure this file exists and that you have spelt the variable correctly?
  14. To get you script to display the uploaded profile picture properly you'll need to do as max_qyver suggested, There is another approach to this and that's to not to store actual raw image in the database. When the image is uploaded save the image to servers file system, for example http://mysite.com/images/profiles/<users-profile-image-name>.jpg. Store only this file path to the database. Your existing code for displaying the image should work. So you should be able to change this line $image = addslashes(file_get_contents($_FILES['profile']['tmp_name'])); to // where to save the uploaded image to $image = './images/profiles/' . $_FILES['profile']['name']; // save the uploaded file to ./images/profiles foler move_uploaded_file($_FILES["file"]["tmp_name"], $SERVER['DOCUMENT_ROOT'] . $image); $image will not contain a file path to the uploaded image. You save this path to the database. This line echo '<img src="', $user_data['profile'], '" alt="', $user_data['first_name'], '\'s Profile Image">'; should work as expected
  15. In your first post the code looks ok. I can't see any errors. The problem is your query does not appear to returning any results. This is why the foreach loop is returning an error on line 18. You should check that your query returned any results using mysqli_num_rows before processing the results on line 18. For example: // check that the query returned any results if(mysqli_num_results($all)) { // process results foreach ($results as $catName => $catData) { print('<b><br><font face=tahoma size=4>'.$catName.'</b><br/></font>'."\n"); foreach ($catData as $itemNum => $itemData) { // if you want to access the row data in this loop, use the following method: print($itemData['descrip'].', '.$itemData['brand'].', '.$itemData['size'].', '.$itemData['flavor'].' - '.$itemData['quant'].'<br/>'."\n"); // etc. (you must code the field names in hard coded this way) //foreach ($itemData as $fieldName => $value) } } } // no results found, display a message or error else { echo 'No results found! Possibly an error:' . mysqli_error($dbc); }
  16. data.json contains valid json data on each line. All you need to do is loop through each line and parse the json data. Assign each type to a $votes array. Then count the values. Example code $file = file('data.json'); // each line gets added to the $file array $votes = array(); // initiate $votes to an array foreach($file as $line) { $vote = json_decode($line, true); // json decode current line $votes[] = $vote['type']; // add vote to array } // display votes count echo '<pre>'.print_r(array_count_values($votes)],1).'</pre>';
  17. The two lines of code is assigning a SQL (cee-qual) command to a variable named $sql. Strings are contained within quotes. The dot (.) is the concatenation operator. This operator joins two strings together example $var1 = 'hello'; $var2 = ' world'; echo $var1 . $var2; The above will output the text hello world
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.