Jump to content

jeff5656

Members
  • Posts

    744
  • Joined

  • Last visited

Everything posted by jeff5656

  1. I even tried this inside php but the leading spaces are still there: $query = "update procedures set cpt = trim(cpt)"; mysql_query($query) or die(mysql_error());
  2. Ok this is weird I used the above: UPDATE sheet2 SET cpt = TRIM(cpt) and it worked. But then I went to another table which also has leading zeros: UPDATE procedures SET cpt = TRIM(cpt) and it said zero rows effected. I then went in and the leading spaces are still there for all the cpt entries!
  3. You guys are smart - I looked, and there is a leading space in front of each value on the cpt field!
  4. Yes I did in fact import that from excel (I cant remember if I did it as xls or csv). How can I examine the cpt field to see if there are hidden characters?
  5. I have a table called sheet2 and I can't get this to echo out when I choose the field cpt: $query2 = "select * from sheet2 where cpt = '9921X' "; $res2=mysql_query($query2) or die(mysql_error()); while ($rvu_array = mysql_fetch_assoc($res2)){ echo $rvu_array['cpt']." ".$rvu_array['rvu']."<br>"; } And 9921X DOES exist as one of the records in that table. If I do anything else like: $query2 = "select * from sheet2 where rvu = '0.18' "; $res2=mysql_query($query2) or die(mysql_error()); while ($rvu_array = mysql_fetch_assoc($res2)){ echo $rvu_array['cpt']." ".$rvu_array['rvu']."<br>"; } it DOES echo out the records where the rvu field has 0.18 as a value. Why on earth would this not work? I searched for cpt as a reserved word but I didn't see that as a reserved word anywhere. here's my table structure: CREATE TABLE IF NOT EXISTS `sheet2` ( `cpt` varchar(7) NOT NULL default '', `Descript` varchar(640) default NULL, `prof_charge` int(3) default NULL, `rvu` decimal(3,2) default NULL, `Medicare_Prof` decimal(16,2) default NULL, `BX_ Prof` decimal(17,2) default NULL, PRIMARY KEY (`cpt`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  6. explode(', ',$row['full_name']); did it. Thanks!
  7. I have a variable called $row['full_name'] that is usually like this : Smith, John. I want to split it into 2 variables for first and last names like this: $query = "SELECT full_name, id_incr from name_db"; $results = mysql_query ($query); while ($row = mysql_fetch_array ($results)){ $newlastname = $row['full_name']; if (preg_match('/^[^,]+(?=,)/', $row['full_name'], $match)) { $newlastname = $match[0]; echo $newlastname; } The $newlastname is: Smith. So far so good. But then, But after I do this: list($newlastname,$newfirstname) = explode(' ',$row['full_name']); echo $newlastname."<br>"; the $newlastname has a comma at the end: Smith, How do I chaneg the explode so that there isn't a comma at the end?
  8. Mind posting the solution so others can reference? But you didn't post your solution for "explode" so others can reference it! :-):-) Anyway mine was : $user = substr($email, 0, strpos($email, "@")); I didn't realize there were so many ways to skin this cat...Good future reference
  9. I ended up using substr and strpos
  10. If I have this string: tester123@somplace.com How do I do it so that I can echo out: tester123 Thanks!
  11. Actually I'm just the opposite. I'm too lazy to understand how to store and retrieve arrays so I just make another table in the database :-)
  12. To me (with limited experience) this makes perfect sense to me: SELECT * FROM main_table a WHERE NOT EXISTS( SELECT * FROM some_table b WHERE a.id = b.id) Can you show what the left join null code would look like? I would like to see the "correct" way (or "parser way" as you guys were saying)..
  13. Ok I'm sorry I think I just wasted all of your time. I was not naming the databases correctrly. for example the database is called myusername_demo NOT demo I a really sorry but at least I still needed the correct JOIN command which you guys did help me with so all is not lost! Thanks again...
  14. "Then your GRANTs are incorrect." I can connect to both databases individually (just tried it) - but when I try to connect to both simultaneously with the above query I get the error.
  15. I get the same arror except it says SELECT command denied to user 'user_nameofdb'@'localhost' for table 'notes_list' Since the username and pw are the same for both databases, I wonder why this doesn't work...
  16. here's the connect code right before that query: $dbhost = "localhost"; $dbname = "xxxx_mainbill"; $dbuser = "xxxxx_yyyy"; $dbpass = "xxxxx"; mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); Importantly, the dbuser and dbpassword is the same for the other database (demo)
  17. Thanks - now I get a new error: SELECT command denied to user 'user_nameofdb'@'localhost' for table 'notes' So my question now is, how do I connect to 2 databases in order to run this query? I think that's the problem...
  18. I'm trying to join the table notes (in the mainbill database) with the table notes_list (in the demo database). the join is via id (in the notes table) with bill_id (in the notes_id table).
  19. I trying to join two tables in 2 separate databases, mainbill and demo. $query2 = "SELECT * FROM mainbill.notes inner join mainbill.notes ON mainbill.notes.id = demo.notes_list.bill_id"; When I run this query I get: Not unique table/alias: notes. Now I do not have a notes table in the demo database so I can't figure out what the problem is. Both databases are on the same server.
  20. Ok I have this query: $query = "SELECT *, u.lname as lastname, todo_patients.lname as todolname FROM todo_list inner join todo_patients on (todo_list.pt_id = todo_patients.id ) INNER JOIN users u ON u.id = todo_patients.user_id" how do I re do that so that only UNIQUE users are selected? (from the users table with the alias of u) Do I use "DISTINCT", and if so how do I put it into the above without causing a syntax error? :-)
  21. I have a script that backs up using mysqldump. The script saves to /tmp which is ABOVE the public_html (WWW) directory. Question: where do I put this script and how do I write the php to correctly point to the tmp directory? If I put the file above the WWW directory, I won't be able to run it from the web I assume. Once I get this to work I;m going to try to figure out how to set up a cron job, but first thing is to learn how to write to the tmp directory (before mailing the backup to a gmail address)
  22. when user logs in they get $this_session = session_id(); When they log out I do : session_destroy(); But when they log back in, the session_id() value is the same as the previous log-in! How do I reset this to be unique, and why doesn't session destroy do that?
  23. "Okay, now I see what you're trying to do. Try this then:" That did it. Thanks!
  24. This doesn't work: for($i=0;$i<$_POST['num_variables'];$i++) { echo $i.": ".$_POST['variable'][$i]."<br>"; } I get 1: 2: 3: But it's blank. I want to echo $_POST['variable1'] but instead of 1 I am using $i in the loop, but when i do this: echo $_POST['variable'] [$i] it is blank!
  25. I have a form that has variables with a number at the end. When user hits submit, I want to echo them all out in a while loop. The names of these variables are the same except for the number, i.e. variable1, variable2, etc. How do I do this? the number of variables is : $_POST['num_variables'] $i = 0; while ($i++ < $_POST['num_variables']) { echo $_POST['variable'] <---- where do I put the $i? is it $_POST['variable'.$i]??
×
×
  • 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.