Jump to content

maxxd

Gurus
  • Posts

    1,652
  • Joined

  • Last visited

  • Days Won

    51

Everything posted by maxxd

  1. If the address is spelled correctly and you're still getting redirected, the DNS hasn't resolved. Try accessing the site by IP instead.
  2. Are you developing locally or on a remote server? If you're local, you'll more than likely enter 'http://localhost/path/to/site' in the browser's location bar. If remote, make sure you're spelling the site address correctly.
  3. Your mysqli_connect() parameters are incorrect. It's mysqli_connect({hostname},{username},{password},{databasename}); You're currently skipping the host and adding a table name.
  4. To tell you true, I think you might want to reconsider using the JQueryUI tabs widget using the script bit I posted earlier. On a site I currently maintain, I've got a widget containing between 2 and 14 tabs per each of 51 JQueryUI accordion divs, and it was a snap to set up. But that's neither here nor there, really... As it stands now, I think your best bet will be to pass the open tab as a GET parameter (or hash, as suggested above), pull the value, loop through all the tabs on the page, run makeInactive() and divHide() on each of them, then run makeActive() and divShow() on the div you pulled from the GET parameter. It's a bit long-winded, I personally think, but it should get the job done with the setup you've got now. PS - if that's your real database password in the mysqli() instantiation in your sample code, please edit the post to remove it and immediately change that password for your site.
  5. Wow. Somehow, through all of this, I read that it was a JQueryUI tabs widget. Literally the entire time. Perhaps I've got more going on today at work than I thought I did...
  6. Correct - put it between the $(function(){ and }); lines that surround the $( "#datepicker" ).datepicker(); line. Again, I make no guarantee about cut-n-paste functionality, but it's a place to start.
  7. Try this (no guarantees, mind you...) var curTab = window.location.hash; if( curTab !== '' ){ $('#simple-tabs').tabs( { active: curTab }); } By the way, you can use one set of <script> tags to define all your javascript functions.
  8. As KevinM1 points out, the first thing you want to do is acquaint yourself with some database theory (nice article, BTW). The table structure you define in your original queries doesn't look bad depending on the content of the 'answers' column in the answers table, but that's outside the scope of this question. Basically, I'd do something along the lines of SELECT q.question_id ,q.question ,a.id AS answer_id ,a.answers FROM questions q LEFT JOIN answers a ON q.question_id = a.question_id If you're feeling real adventurous, you can add an ORDER BY RAND() clause and try to limit the response to one question in order to avoid having to do it in PHP. Once you've got your record set returned (for this example, I'm assuming in an associative array called $result), try something along the lines of the following: <h2><?php echo $result['question'] ?></h2> <input type="hidden" name="question_id" value="<?php echo $result['question_ID']; ?>" id="question<?php echo $result['question_ID']; ?>_id"/> <?php foreach( $result as $answer ){ echo "<label for='q{$answer['[answer_id']}'>{$answer['answers']}</label>"; echo "<input name='answer_{$answer['question_id']}' id='q{$answer['answer_id']}' value='{$answer['answer_id']}' type='radio'/>"; } ?> As an aside, I wouldn't bother selecting the 'a.correct' column while ouputting the question and answer - you're not going to need that information until you grade the answer (after form submission). Also, I should think it goes without saying, but this won't work if you want to display more than 1 question at a time, but you get the general idea I hope.
  9. I think - and honestly I'm not entirely sure so check the docs - that you can target a specific JQueryUI tab by appending a target anchor to the end of your url. So, if you typically submit to 'myPage.php', try changing it to 'myPage.php#tabUpdate' and that may do what you're looking for. Basically, you can append the ID of the list item and it might do that automatically. If not, it should be easy enough to write out a little script that activates the specified tab on page load.
  10. Couple things here. First, I may be missing it but I'm not seeing where you're setting the $answers variable. Or the $question variable, for that matter - are you not showing some looping? In addition, if your script is giving you anything other than an array to string conversion error, you're printing the same string ($answers) over and over again. Your initial queries could be rewritten using a join to be a single call to the database as well. There are a couple different ways to get one random question and it's associated answers without having to load the entire contents of both tables into an array.
  11. Ah - remove the '$' in front of the array() keyword. In other words, instead of $arr = $array('email'=>$email); use $arr = array('email'=>$email);
  12. What does ArrayBinder() look like? Everything looks ok (please use the code tags in the future - they make your code much easier to read) at first glance. Usually the error message will give you a line number and file name. That'll help you pin down where the actual problem is happening.
  13. You've got 8 columns listed, and only 7 values - looks like confirmusername.
  14. Your while loop is specifying which values you're using. Instead of this: while($array = mysql_fetch_array($result)){ $data[$array['date']][$array['id']] = $array['type']; } try this: while($array = mysql_fetch_array($result)){ $data[$array['date'][] = $array; } That should give you a date-indexed associative array of all the values in each row of the result set.
  15. You're getting the number of rows in the table on line 113, inserting a record on 117, then checking the number of rows in the table on 118. Unless the insert fails, the total on line 118 is always going to be 1 more than the total on line 113. If you want to e-mail yourself only after 50 records have been inserted, get the total number of rows in the table *before* your foreach() loop, add 50 to that, and increment a counter inside your foreach(). Once the counter plus the initial row count equals or is greater than the initial row count plus your cut-off for not sending e-mails, send yourself an e-mail.
  16. You're not using the user-submitted data in testdata.php. You use $username, $userlevel, $email, and $id in the query, but they're not set from $_POST - nor are they sanitized, which leaves you wide open to all kinds of injection. Also, the mysql functions have been deprecated and are scheduled to be removed soon - use mysqli or pdo.
  17. Upload the files to the server (you can check file type in a couple different ways for safety), then store the link to the uploaded file in the database. http://www.php.net/manual/en/features.file-upload.php should get you started on the upload process if you're having trouble with that part - I believe there's a decent explanation of file type checking in there.
  18. Right off the top, I don't see where you're declaring $selecteddate. You've got $selectedfromdate and $selectedtodate as parameters of print_log_selector_form_range(), but there's a content check on $selecteddate that doesn't exist. I don't see where else it's used in the function either, but I haven't had my third cup of coffee yet this morning. Add error_reporting(-1); to the top of your index page and see what it has to say.
  19. 'name' is a Users() property. In order to access it, you'll need to use $users->name instead of $this->name in form.php, just as you do with the $table instance of the create_checkout_table() class.
  20. You've got a couple things wrong here, I think. Try this: $pwd = ($_POST['pwd']); $query = "SELECT empid FROM users WHERE empid='{$pwd}'"; $sql = mysql_query($query); $result = mysql_fetch_assoc($sql); if ($pwd == $result['empid']) { header("Location: setpass.php?msg=ERROR: you dont have the password...."); } First off, the SQL was a bit malformed - on line 5 it looks like you're using the value in $pwd as the column header, and the value has to by 'empid'. You're also not actually getting the result set from the query process. By calling mysql_fetch_assoc(), you're putting the result set into an associative array (line 7). You were also using the assignment operator (=) in your comparator on line 9. Use the comparison operator (==).
  21. Psycho's correct - don't select the actual empid, select the count of returned records. Check the SQL in post #6 to see the difference in the SELECT line, or use mysql_num_rows() as in the post above. Either way, make sure you're comparing integer to integer, and you should optimally only get one returned row in the recordset.
  22. Hey y'all. I'm having (I think) a senior moment here with something I'm working on. I've got a small database abstraction class that I've written, and I'm trying to do as little work as possible to extend it a bit. Basically, I don't want to have to do a simple deferral method to go from my client code to the mysqli instance, but I also want some control over some of the mysqli functionality. So I'm attempting to implement a __call() magic method that'll pass the method through to the internal mysqli instance. Here's the method: class myDBAbstraction{ /* other stuff.... */ public function __call($method, $args){ if(method_exists($this->_conn,$method)){ $tmp = $this->_conn->$method($args); if($tmp === false){ die("<p>Error {$this->_conn->errno}: {$this->_conn->error}</p>"); } return $tmp; } $this->error = "Bad call: {$method}"; return false; } } Note that $this->_conn is a mysqli() instance stored as a private class property. The call is simple: class myClientTester{ /* I instantiate a myDBAbstraction() instance as $this->_conn for this class. I'm very original with naming conventions... */ public function testing(){ if($this->_conn->prepare('UPDATE tbl_copy SET cpy = ? ,last_edited = UTC_TIMESTAMP() ,last_edited_by = ? WHERE pg = ?')){ $this->_conn->close(); die("<p>Statement prepared</p>"); }else{ die("<p>Error: {$this->_conn->error}</p>"); } } } I'm literally just trying to get so far as to prepare the statement - I'll work on the rest later. However, the call to mysqli::prepare() fails. It returns false but myDBAbstraction::$_conn->errno = 0 and myDBAbstraction::$_conn->error is null. Anyone have any ideas as to what I'm doing wrong here? Much thanks in advance for any ideas or advice!
  23. Weird - what's happening now? Is it not redirecting at all or is it throwing an error? Try var_dump()'ing $res as well as printing the $qry string just to make sure you've got everything you need. I'm assuming you've got error_reporting() turned on and set to report all errors, right?
  24. So basically you're (not eactly, but kind of) creating a temporary password that matches the user name when a user registers, right? In that case, don't bother encrypting the _POST['pwd'] value before you do the comparison. The rest of it should work for you, though - you've got the empid already, so there's not really a need to pull that from the database before you redirect the user; this means a simple count should still work as described above with only a couple tweaks. You may want to extend this to select only records where empid == $_POST['pwd'] and your password field is empty - this could help disambiguate the record and also make certain it's a new user that has a user name but not a password. However, that's internal business logic and not my place (I just thought I'd throw it out there). $qry = "SELECT COUNT(*) AS numUsers FROM users WHERE empid='{$_POST['pwd']}'"; $sql = mysql_query($qry); $res = mysql_fetch_array($sql); if($res['numUsers'] == 1){ header("Location: setpass.php?msg=ERROR: you dont have the password...."); } Please note the above does not even begin to deal with any database safety and I wouldn't ever recommend putting a user-submitted value directly into a query string without some sort of sanitization.
  25. $dt = new DateTime('now'); $qry = "select count(*) from clanovi_njihovi_parovi where status = 1 and racun=r.id and datum BETWEEN '{$dt->format('Y-m-d')}' AND '{$dt->sub(DateInterval::createFromDateString('7 days'))->format('Y-m-d')}'"; That's off the top of my head, but should get you started - the php DateTime() docs are comprehensive. Also, I know the statement will parse in SQL Server, but unfortunately I don't use MySQL at work so the syntax might be slightly different.
×
×
  • 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.