Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. Quick glance. Could it be because in one place you reference username and the other userName?
  2. Something looks fishy after your run your query. You destroy the query result with your weird test of the query success. After that I don't know what you may be seeing. It should resemble this pseudo-code: $result = MySQL_query( your query string) or die("query failed"); while ($row = MySQL_fetch_assoc($result)) { process result row }
  3. Thank you for your support Kicken - at least someone understands where I'm coming from. With that said - I think I'll sign off this post. Can't fix ...... Well you know what I mean.
  4. show us the line where you check the result of your execute statement. Prove to us that the line ran and we're not looking at a duplicate record. Or perhaps add a retrieval query and output the results of your insert. Do Something to solve this yourself instead of whining about what to do.
  5. Actually my code is exactly correct - regardless of your opinion of aesthetics. One thing I realized last night in bed was I left out the display of a line that did not make a category break. The following needs to be added: if ($cat_c <> $last_c) { show_totals('c'); output row of data but skip columns for both cat_a & cat_b add_totals(); } ELSE { output row of data but skip cols for cat-a, cat-b & cat-c add_totals(); } Left out the simple case! As for comments - the comments are there for a reason. And the functions were not fleshed out since this is ONLY A TEMPLATE for the OP to use to achieve his goals.
  6. show us some code. NOT ALL of it - just the part that is pertinent to this whole retrieval of inputs, creation of query and execution - AND the check that the query actually ran!
  7. Hate to step in, but I think the following code will do the job correctly. ..... // to show data in sequence of cat_a,cat_b, cat_c but only show those fields at beginning // of the group. $q = "select * from tablename order by cat_a, cat_b, cat_c"; if (!$qrslts= $pdo->query($q)) { echo "Error in query"; exit(); } // // now begin the output process // $firstrow = true; $last_a = "xxx"; $last_b = "xxx"; $last_c = "xxx"; // define and initialize total vars here // // start your output table here and setup headings. // while ($row = $qrslts->fetch(PDO::FETCH_ASSOC))) { if ($firstrow) { output entire row of data from $row add_totals(); $firstrow = false; } else { if ($cat_a <> $last_a) { show_totals('c'); show_totals('b'); show_totals('a'); output entire row of data from $row add_totals(); } else { if ($cat_b <> $last_b) { show_totals('c'); show_totals('b'); output row of data but skip column for cat_a add_totals(); } else { if ($cat_c <> $last_c) { show_totals('c'); output row of data but skip columns for both cat_a & cat_b add_totals(); } } } } // save the last shown cat values after every output. $last_a = $row['cat_a']; $last_b = $row['cat_b']; $last_c = $row['cat_c']; } // finished with data - show final totals. show_totals('c'); show_totals('b'); show_totals('a'); //********************** /* note 1 - the show totals functions are only necessary if you need totals at the end of each category break(change). note 2 - the best way to output this kind of data is to use a table and simply output a blank td element when trying to not show a category/column. */
  8. The way to do it is to sort your query by the type_a and type_b fields in that order. Then in your output keep track of the header fields that are displayed and don't show them until they change again.
  9. Thought I knew what you wanted til I read this: populate base on the choice made Huh?
  10. my code? I just gave you what you had. I've never tried to play music on my web pages. Nope - that was your code with those headers
  11. Didn't work, did it? There's a lot of wrong stuff out there googleland. Keep trying.
  12. Try turning error checking and you'll see. ALWAYS CHECK FOR ERRORS IN YOUR CODE!
  13. He is asking you 'What are the field types of the ones you are not using bound params for?'. (You really should have known that)
  14. Why not google 'how to play music from my web page'?
  15. try using the in clause as in: $result = mysql_query("SELECT id, ans FROM questions WHERE id in ['$id']"); (Note how I used single quotes) where you build $vals in your loop and execute the query outside the loop. and $vals is a comma-separated string of values.
  16. But you really should get rid of the class thing. Adds needless complication and overhead to your code. And it's not practical since you don't parameterize the dbname. require_once($php_path."/pdo_connect_select.php"); // contains PDOConnect function $pdo = PDOConnect("mydbname"); $q = "select * from table ...... "; $qst = $pdo->prepare($q); $qst->execute(); And the included/required file (pdo_connect_select.php) is: function PDOConnect($dbname) { $host="mysql:host=domain.com;dbname=$dbname;charset=utf8"; $uid = "myuser"; $pswd = "mypswd"; Try { $mysql = new PDO($host,$uid,$pswd); } catch (PDOException $e) { echo "Fatal Error<br>Failed to connect to mysql via PDO. PDO Error msg is:<br>".$e->getMessage(); return false; } if (!$mysql) { echo "Failed to connect to mysql via PDO. Error returned is: " . GetPDO_ErrorMsg($mysql); return false; } else return $mysql; } //***************************** function GetPDO_ErrorMsg($pdo,$i = 2) { $pdo_errinfo = $pdo->ErrorInfo(); return $pdo_errinfo[$i]; }
  17. You are not connected to your db. Ignore the rest of the code and check on your connection and be sure it happens.
  18. Do you know what a link is? And why do you have those header calls in there? If all you want is to display an html page with a link no it get rid of them.
  19. 1 - no need to complicate your life and make a class out of this. Just take that simple code and made it an include file for it. 2 - you created the var $con as an object of connection type. 3 - you executed dbconnect for that object. And - what? You have no pdo connection variable. See how the class made things so complex? $pdo = $con->dbConnect(); $stmt = $pdo->prepare(..... Tip - make the dbname an argument of your dbconnect function (which is all you need) and then you won't have to have a different one for every db you have. (Assuming you use the same master id/pswd for all your dbs)
  20. You're off the track. Try this code. <?php $songsfolder = "songs"; header("Content-Type: audio/x-mpegurl"); $body = ''; $songs = glob($songsfolder."/*.mp3"); if (count($songs) == 0) { echo "Error - no songs found"; exit(); } shuffle($songs); $body .= "http://" . $_SERVER['HTTP_HOST'] . $songs[0]; header('Content-Length: ' . strlen($body)); echo $body; ?> Not sure about the syntax of my $body content since it's been awhile since I used glob and pathinfo functions. You may have to add a slash or another folder reference, but this will do what you want. Plus - not sure what at all you expect this to do since you are simply echoing a text line that has a url in it, but you have specified headers that imply something else. AND - your original post mentioned a "link", which is not in your code either. And it does it without using offensive or childish function names.
  21. If you are tracking job openings I would think you need the following: jobs table - job id,employer_id, cols for specific items related to each job, cols to track the status of the job (closed, open, etc.) employer table - info about the companies with job openings with an id to tie it to the jobs they give you. May have multiple records for an employer if they have diff addresses, or contact people. client table - to track your potential clients and link them to jobs they have seen to avoid duplicating any emailing or stuff you do with all this info. Or if you don't care and this is a one-way system you don't need this table.
  22. Since those tables all have the exact same symbolic structure, I'm wondering why you don't have their data all in one table. That would be normalization. What makes it necessary to store those records in 3 separate tables?
  23. Queries don't return arrays. Why do you need so many queries? Is your db not normalized properly? From the sound of your project, You s/b able to pull up the info you need with a properly written query and then be able to process that resource and display it all in one pass.
  24. What timezone do you want to use? Or is it based on the location of the client? PHP is going to give you the time that is set in the .ini file, which probably is related to the location of the server farm. If you're not setting it, then perhaps the default is set by GD and you should use phpinfo to determine what it is. If it's not what you want, read up on how to modify php.ini settings. (Hint: search the php manual) I'm no expert on handling times in zones related to the client, so I may be of no help here. But if you are the one seeing the problem, I think it's what I said above.
×
×
  • 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.