Jump to content

QuickOldCar

Staff Alumni
  • Posts

    2,972
  • Joined

  • Last visited

  • Days Won

    28

Everything posted by QuickOldCar

  1. I find it easier to build the array and check it, once the data is as expected, then send as json and just send the main array. $output = array(); //in a loop adding to the array $output[] = array($time[0], $temperature[0], $current[0],$wind[0],); or assigning key values $output[] = array("time"=>$time[0], "temperature"=>$temperature[0], "current"=>$current[0],"wind"=>$wind[0],); does it look right? var_dump($output); or echo "<pre>"; print_r($output); echo "<pre>"; If that array is good then echo it out, and comment out anything that echoes prior. As Ch0cu3r mentioned do not add html, sending json is just for data and not style. Do that if need to optionally when getting the request for display. header('Content-Type: application/json; charset=utf-8'); echo json_encode(array('data' => $output),true);
  2. I don't see why you don't place these files into the root directory | | ==> pages/ | | ==> templates/ | | ==> templates_c/ | | ==> index.php Anyway, make sure mod_rewrite is enabled on the server. Restart apache after making the changes. In .htaccess RewriteEngine On RewriteBase / RewriteRule ^frontend/(.*)$ /$1 [R=301,NC,L]
  3. You can not place it in a frontend folder, or do an apache/htaccess rewrite rule
  4. Old 16 character long password hash? Did php or mysql get updated? http://dev.mysql.com/doc/refman/5.7/en/set-password.html SET PASSWORD FOR 'username'@'localhost' = PASSWORD('thepassword') Basically you need to set the password again You can look in my.cnf and comment out this line, restart the server old-passwords = 1
  5. You can add opengraph metadata as well.
  6. <meta itemprop="price" content="<?php echo $this->getPriceHtml($_product, true); ?>" />
  7. This is bbcode used within an editor [restrict userlevel="subscriber"][masterslider id="1"][/restrict] To paste directly into a theme you use normal php code and echo the function/plugin parameters. Or you use wordpress built in do_shortcode() function. https://developer.wordpress.org/reference/functions/do_shortcode/ <?php if ( is_user_logged_in() ){ echo do_shortcode( '[restrict userlevel="subscriber"][masterslider id="1"][/restrict]' ); } ?>
  8. Any objective comments would be nitpicking, it looks and functions just fine.
  9. Can you explain more what you are doing? Am sure is a better way to do whatever is trying to accomplish. You can add a meta refresh to the visited script with a delay and use the referrer as the location. I added a check for the scripts url so does not keep refreshing in a loop. 5 second delay, not sure what doing upon visit <?php $httpreferrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; $this_url = filter_var("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'], FILTER_SANITIZE_STRING); if (!empty($_SERVER['QUERY_STRING'])) { $this_url .= "?" . filter_var($_SERVER['QUERY_STRING'], FILTER_SANITIZE_STRING); } if ($httpreferrer && $httpreferrer != $this_url) { echo "<META http-equiv='refresh' content='5;URL=$httpreferrer'> "; } ?> If it's some remote site you need to make a script with this code and iframe that website. Many sites block iframes now or have jump out of frame scripts.
  10. Can look into stripe or paypal as a payment gateway. So that is just the part them purchasing credit packages x amounts. Check request and verify they actually paid, once get that add the credits to their account. As for on site is a matter of doing a -1 for their credits upon usage. When out of credits a reminder or link to purchase more credits.
  11. Have to watch out for multibyte characters and may want to do mb_substr(trim($group['lastname']), 0, 1, 'utf-8') Could also do $group['lastname'][0]
  12. When kids talk in class, here is how they handle the punishment. for($i=1;$i<=1000;$i++){ echo "I will not talk in class.
    "; }

  13. The best thing about a Boolean is even if you are wrong, you are only off by a bit.

  14. Not really the best example to learn, assumes have cpanel, uses short tags, allows empty POST values and also deprecated mysql_* functions If you have phpmyadmin that's fine for setting up databases. For database connections and manipulating data learn PDO or mysqli_* and use prepared statements If use mysqli_* be sure to use mysqli_real_escape_string() Also look into doing better error checking plus also checking if the request exists, data types and values from the form before using them.
  15. Welcome Bill. I personally stick to json, xml has many types and also could have malformed issues a lot. http://json.org/ json_encode() json_decode() Although I do output multiple formats using header types in my api's like html,json,xml. But that is my own data knowing is encoded and cleaned properly.
  16. Welcome to the site elemen121
  17. using explode() will explode the string back into an array at whatever delimeter use $array = explode("||",$data);
  18. Arrays in stored procedures are not supported and can get messy. What you should do is normalization in a relational database instead. Splitting your data first and importing it into a database the way you intend to use it. Split the array prior and insert each as it's own id while associating it to whatever user/group/values id another table you intend on keeping it associated to. If insist on doing it as trying to save arrays, you have to come up with your own method that can work for you. Usually can pass a comma delimited string or split the data a delimiter would possibly never use such as a double pipe || Pass the string and store as VARCHAR(255) to the stored procedure. Inside the procedure you can split the string back into its elements. Can also look into serialize and unserialize
  19. Use the mysqli_* functions instead http://php.net/manual/en/book.mysqli.php http://php.net/manual/en/mysqli.quickstart.connections.php http://php.net/manual/en/mysqli.select-db.php Escape anything being used in mysql queries http://php.net/manual/en/mysqli.real-escape-string.php http://php.net/manual/en/mysqli.query.php http://php.net/manual/en/mysqli.close.php
  20. You can use list() or implode() them and comma separated If happened to pass them through a loop can also build a string using concatenating assignment operator .=
  21. Does seem like is a loop, is most likely doing the output buffering or running function multiple times, so the require_once is meaningless since calls function each time. In the same way can add an action can also remove it from specific areas remove_action() As for your is_admin(), use something like this if ever need it. if(current_user_can('manage_options') || is_super_admin()) {
  22. See just a few I found with e modifier? remove those if exist all 973 lines of code. $pattern = array('%\[list(?:=([1a*]))?+\]((??>.*?(?=\[list(?:=[1a*])?+\]|\[/list\]))|(?R))*)\[/list\]%ise'); $pattern[] = '%\[list(?:=([1a*]))?+\]((??>.*?(?=\[list(?:=[1a*])?+\]|\[/list\]))|(?R))*)\[/list\]%ise'; $pattern[] = '#\[img\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e'; $pattern[] = '#\[img=([^\[]*?)\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e'; $pattern[] = '#\[url\]([^\[]*?)\[/url\]#e'; $pattern[] = '#\[url=([^\[]+?)\](.*?)\[/url\]#e';
  23. strip_tags is doing you no good here $mydesc = strip_tags($_POST['mydesc']); You want to escape the data before inserting into mysql with mysqli_real_escape_string() As for character encoding and quotes back and forth to and from database back into html is a lot to go over, instead will link you to functions, you should know what they do before using them. trim() that incoming data of any whitespace html_entity_decode() htmlentities() htmlspecialchars_decode() htmlspecialchars() If your script works in one and not the other must be differences in php versions, php settings or server configuration Ensure magic_quotes is disabled
  24. You should do each value in it's own named column. Use auto increment for the id. Then use a LIKE comparison or use fulltext search in booleon mode
  25. This should be better with the changes. Should have a bit more error checking in this though. <?php session_start(); // Connect to MySQL $conn = mysqli_connect("localhost", "root", "", "hsa_project_hub"); if (!$_SESSION['admin_login']) { header("location: admin_login.php"); exit; } $id = ''; // Grab user id from admin_userList.php and pull user info from database if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = $_GET['id']; $sql = "select * from hsa_users where id='$id'"; $result = mysqli_query($conn, $sql); $row = mysqli_fetch_assoc($result); $run = mysqli_query($conn, $sql); $row = mysqli_fetch_array($run); $id = $row['id']; $user_firstName = $row['user_firstName']; $user_lastName = $row['user_lastName']; $user_company = $row['user_company']; $user_discipline = $row['user_discipline']; $user_email = $row['user_email']; $user_loginName = $row['user_loginName']; $user_pass = $row['user_pass']; $email_alerts = $row['email_alerts']; } //getting the text information and saving in local variables if (isset($_POST['update'])) { if (isset($_POST['id']) && is_numeric($_POST['id'])) { $id = $_POST['id']; } $user_firstName = mysqli_real_escape_string($conn, $_POST['user_firstName']); $user_lastName = mysqli_real_escape_string($conn, $_POST['user_lastName']); $user_company = mysqli_real_escape_string($conn, $_POST['user_company']); $user_discipline = mysqli_real_escape_string($conn, $_POST['user_discipline']); $user_email = mysqli_real_escape_string($conn, $_POST['user_email']); $user_loginName = mysqli_real_escape_string($conn, $_POST['user_loginName']); $user_pass = mysqli_real_escape_string($conn, $_POST['user_pass']); $email_alerts = mysqli_real_escape_string($conn, $_POST['email_alerts']); $update = "UPDATE hsa_users SET `user_firstName`='$user_firstName', `user_lastName`='$user_lastName', `user_company`='$user_company', `user_discipline`='$user_discipline', `user_email`='$user_email', `user_loginName`='$user_loginName', `user_pass`='$user_pass', `email_alerts`='$email_alerts' WHERE id=$id"; $run_update = mysqli_query($conn, $update); if ($run_update) { echo "<script>alert('User has been successfully updated.')</script>"; echo "<script>window.open('admin_userlist.php','_self')</script>"; } } ?> <!DOCTYPE HTML> <html> <head> <title>Project Hub New User</title> <link href="hsastyle.css" rel="stylesheet"> </head> <body> <div id="main_container"> <p><em>version 1.0 beta</em></p> <div id="banner"> <div id="logo"> <img src="images/hsa-logo.jpg" alt=HSA logo> </div> <a href = "admin.php"> <H2><em>Admin Panel</em></h2> <H5><a href="adminLogout.php">Log Out</a></H5> <H6>Welcome <?php echo $_SESSION['admin_login'];?> </a> </div> <!--End Banner--> <!--form for adding users--> <h1 align="center">Edit User</h1> <form action="edit_user.php" method="post"> <input type="hidden" name="id" value="<?php echo $id;?>"/> <table align="center" bgcolor="d8d8d8" width="960"> <tr align="center"> </tr> <tr> <td align="right"><strong>First Name:</strong></td> <td> <input type="text" name="user_firstName" value="<?php echo $user_firstName;?>"/> </td> </tr> <tr> <td align="right"><strong>Last Name:</strong></td> <td> <input type="text" name="user_lastName" value="<?php echo $user_lastName;?>"/> </td> </tr> <tr> <td align="right"><strong>Company:</strong></td> <td> <input type="text" name="user_company" value="<?php echo $user_company;?>"/> </td> </tr> <tr> <td align="right"><strong>Discipline:</strong></td> <td> <select name="user_discipline"> <option><?php echo $user_discipline;?></option> <option>Architect</option> <option>General Contractor</option> <option>Owner</option> <option>Structural Engineer</option> <option>MEP Engineer</option> <option>Civil Engineer</option> <option>Landscape Architect</option> <option>Developer</option> </select> </td> </tr> <tr> <td align="right"><strong>Email:</strong></td> <td> <input type="email" name="user_email" value="<?php echo $user_email;?>"/> </td> </tr> <tr> <td align="right"><strong>Log In Name:</strong></td> <td> <input type="text" name="user_loginName" value="<?php echo $user_loginName;?>"/> </td> </tr> <tr> <td align="right"><strong>Password:</strong></td> <td> <input type="text" name="user_pass" value="<?php echo $user_pass;?>" required="required"/> </td> </tr> <tr> <td align="right"><strong>Email Alerts:</strong></td> <td><br> <input type="radio" name="email_alerts" value="yes">Yes<br> <input type="radio" name="email_alerts" value="no">No </td> </tr> <tr align="left"> <td colspan="6"> <input type="submit" name="update" value="Update"/> </td> </tr> </table> </form> </div> <!--End main container--> </body> </html>
×
×
  • 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.