Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. Every once in awhile someone posts a bizarre php statement that confuses me. Here is yours: session_start(); if(isset($_SESSION['username'])) ?> <?php // Connect database. $con = mysql_connect("*****","*****","*****"); blah blah blah You check if you have defined your username variable in the session and if so ..... What? And if not you do some work, but what for? I'm guessing if the username exists you don't want to do anything, but that's not what I see. Besides - does this code even run without an error or a warning? You've go this dangling if statement.
  2. Despite the overall goal of this exercise, the easy way to accomplish what I think you are asking is (and BTW - try to post a REAL question in your topic header next time!) to make your value attribute contain both things. <option value="#000000|Black">Black Frame</option> Then when you retrieve it do this: $sel_ar = explode("|",$_POST['frame']); This will give you an array with: $sel_ar[0] = "#000000"; $sel_ar[1] = "Black";
  3. Sessions are nothing to worry about - at least as far as storing info goes. You attempt to store a var username in the session array.and then try and retrieve it in another script, but you use the wrong name. Remember - case sensitivity matters. If that is not the problem, then why exactly DO you use two different spellings of the same word as a variable name?
  4. Quick glance. Could it be because in one place you reference username and the other userName?
  5. 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 }
  6. 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.
  7. 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.
  8. Uuuuuhhh... You can show us some code!
  9. 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.
  10. 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!
  11. 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. */
  12. 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.
  13. Thought I knew what you wanted til I read this: populate base on the choice made Huh?
  14. 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
  15. Didn't work, did it? There's a lot of wrong stuff out there googleland. Keep trying.
  16. Try turning error checking and you'll see. ALWAYS CHECK FOR ERRORS IN YOUR CODE!
  17. 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)
  18. Why not google 'how to play music from my web page'?
  19. 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.
  20. 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]; }
  21. You are not connected to your db. Ignore the rest of the code and check on your connection and be sure it happens.
  22. 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.
  23. 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)
  24. 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.
  25. 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.
×
×
  • 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.