Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. You need call mysql_result like this $profile_privacy = mysql_result($result, 0, 0); $profile_pictures = mysql_result($result, 0, 1); BUT you should stop using the mysql_* libraries as these are deprecated functions, which means they are no longer maintained/supported and could soon be removed from future versions of PHP. Instead you should convert your code over to PDO or MySQLi
  2. For each result you need to define a "category" property for the results heading Example $i = 0; while($row = mysqli_fetch_assoc($result)) { $row['category'] = $i++; // define the bottom axis heading $arr[] = $row; }
  3. First you want to work out how to upload files, I would recommend you to read the manual for how PHP handles file uploads Once you have working code uploading files. You can then move on and learn to use unlink for deleting files.
  4. json_encode the results and then assign them to the "dataProvider": property, example AmCharts.makeChart("chartdiv", { "type": "serial", ... "dataProvider": <?php echo json_encode($results); ?>, });
  5. Apply the s pattern modifier to your regex
  6. Yes because on this part of the code you are using raw $_POST data in your query // ****** Setup customized query to obtain only items that are checked ****** $sql = "SELECT * FROM shoplist WHERE"; for($i=0; $i < count($_POST['checkboxes']); $i++) { $sql=$sql . " idnumber=" . $_POST['checkboxes'][$i] . " or"; } $sql= rtrim($sql, "or"); $statement = $conn->prepare($sql); $statement->execute(); ...; And as I stated you are using a prepared queries incorrectly (read my comment at the bottom of post #4)
  7. according to the phpMyAdmin wiki it uses pChart for creating the graphs.
  8. You have way over complicated this. Everything can be handled by just a single update query. So upon the clicking the red button you are setting the value for the purchased column in the table to Y where the records purchase_later_flag flag is not N and the record id matches the id contained in the checkbox value. The operation is then reversed for the blue button (Setting purchased to N and purchaed_later_flag to Y). Example code if(isset($_POST['highlight-purchased'])) { // ****** toggle purchased flag ****** $sql = "UPDATE shoplist SET purchased = 'Y' WHERE purchase_later_flag != 'N' AND idnumber IN(' .implode(',', array_map('intval', $_POST['checkboxes'])). ')'; $conn->query($sql); } // reveres the operation for purchase later if(isset($_POST['highlight-purchase_later'])) { // ****** toggle purchased later flag ****** $sql = "UPDATE shoplist SET purchased_later_flag = 'Y' WHERE purchased != 'Y' AND idnumber IN(' .implode(',', array_map('intval', $_POST['checkboxes'])). ')'; $conn->query($sql); ​} Also you are using prepare statements completely incorrectly, the values used in your prepared queries should be replaced with placeholders. Whereby then you bind the values to the query when you goto execute it. The database will then replace the placeholders with the escaped values. Currently your code is still open to SQL injection.
  9. It is caused by the div as Jacques1 pointed out. So to prevent the break between the Incident and Exit Ramp text you need to remove the <div></div> tags. Example // strip the div tags from the data $incident_data_desc = preg_replace('~^<div[^>]+>(.*?)</div>$~is', '$1', $incident_data_desc);
  10. You dont that is the default...
  11. The file path is most likly wrong Is the html directory your document root? If so the image path should be like <img src="/wvb-logo-slogen.png" border="0" />
  12. To find out why it is failing your need to retrieve the error message from mysqli_error Line 23 of co_handler.php $result = mysqli_query($conn, $sql); if(!$result) trigger_error('MySQL Error: ' . mysqli_error($conn), E_USER_ERROR);
  13. Agreed.. FYI this is what the OP is trying to achieve http://forums.phpfreaks.com/topic/288403-creating-a-single-variable-for-multiple-mysql-returns-of-the-same-data/
  14. What.. that makes no sense when it is full of syntax errors.
  15. str_replace should work just fine, example floatval(str_replace('$', '', $arr[13])); If the data is coming from a csv file, then read the data using fgetcsv
  16. How does your code identify the user is logged in? Also your code has potential for SQL injection attacks because you are not validating and sanitizing the users input before using it in your queries You should not be using wildcard search here. $query = "SELECT * FROM email_activation where username LIKE '%$username%' LIMIT 0 , 1 "; You need to do an absolute match WHERE username ='$username' Also You should also consider converting your code to PDO or mysqli as the mysql_* functions are deprecated and no longer supported.
  17. If you're storing the file location in the database then all you need to do is query the database to return the filepath that matches the fileid, example code <?php $mysqli = new mysqli('localhost', 'user', 'pass', 'database'); if(isset($_GET['fileid']) && ctype_digit($_GET['fileid'])) { // get filepath from database $stmt = $mysqli->prepare('SELECT filepath FROM files_table WHERE file_id = ?'); $stmt->bind_param('i', $_GET['fileid']); $stmt->execute(); $stmt->bind_result($filepath); $stmt->fetch(); // output correct file content/mime type $finfo = new finfo(FILEINFO_MIME); header('Content-Type: ' . $finfo->file($filepath) ); // .. maybe send headers to prevent caching too? // output contents of the file readfile($filepath); exit; } // send 404 error invalid request header("HTTP/1.0 404 Not Found"); exit; However this still wont prevent hotlinking as they can just link directly to getfile.php?fileid=xxxxx
  18. implode $names array into a string, then pass that to preg_match $data = implode("\n", $names); preg_match('~Temperature_Celsius\s+(-?\d+)~', $data, $m); echo 'Temperature Celsius: ' . $m[1];
  19. Either you misspelled the file name, or you are not running the command in the same directory as the txt file.
  20. That shouldn't affect PHP as it uses the file system to access files, not Apache. If PHP cannot access the file then it is either a file permission issue or an open_basedir restriction.
  21. Yes it will return the value that follows Temperature_Celsius Although you'd need to change the \d+ regex to -?\d+ to match negative numbers preg_match('~Temperature_Celsius\s+(-?\d+)~', $data, $m); echo 'Temperature Celsius: ' . $m[1];
  22. Yes, regex would be quicker preg_match('~Temperature_Celsius\s+(\d+)~', $data, $m); echo 'Temperature Celsius: ' . $m[1];
  23. So you have 39 items in the list and you want to distribute them evenly across three columns on your webpage? It would be helpful if you could post an example of the data you're working with and your current code.
  24. You dont need to escape it. $_GET['value'] should be returning 100.00 You may need to post your code.
  25. What is you table structure like? If you are storing the product type in a separate column then you can do select distinct, example $result = $mysqli->query('SELECT DISTINCT product_type FROM products'); if($result) { echo '<select name="type">'; while(list($type) = $mysqli->fetch_row()) { echo "<option>$type</option>"; } echo '</select>'; }
×
×
  • 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.