Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Posts posted by ginerjm

  1. And "status" should be giving you an error since you didn't select it.

     

    Turn on error checking whenever you are writing new code. It helps the process. (See my signature.)

     

    Also - Stop using MySQL* functions. If you bother to read the manual, or ever look at it, you'll see a big red box telling that it is outdated and no longer valid in the current PHP version. Better to stop now than have to come back eventually and re-code.

     

    Lastly - don't use this method of retrieving row data from a query result. Fetch a whole row and reduce your resource utilization. For example - if you are using MySQL* functions, then use the MySQL_fetch_assoc() to get a whole array of the fieldnames in your query results with only call to the interface instead of 3. Plus you don't have to keep a row counter.

    But you should move on to a newer interface - preferably PDO, but that is just my opinion.

  2. did you write this code or copy it from somewhere? So many mistakes.

     

    Try fixing the function at the top. You loop thru the query results in there, saving all the rows values in the same variable. This means you only have the last row's information to work with. Why is that?

     

    In the main line code you are doing this:

    while($row_cat_pro=mysqli_fetch_array($run_cat_pro))
    {
    $pro_diametro = $row_cat_pro['diametro'];
    $link_diametro= "index.php?diametro=$pro_diametro";
    echo "<input type='radio' value='" .$link_diametro ."' >" . $pro_diametro . "</option>";
    }
    

    Why do you echo the start of an input tag and end with a closing option tag??? You do this again later. Do you not know HTML at all?

  3. As a newbie you should make the effort to learn by picking up the manual or a good book and giving it a reading. Look at the syntax sections, how to construct a database 'process' as in: the connection, the query statement preparation, the query, checking the results of the query and then fetching the rows from the query results. All good stuff to learn by yourself and THEN trying to make it work for you and THEN asking for help with it. If you can't understand what you are told, how can we help you?

  4. Once again the failure to include simple PHP error checking during a development costs you time and frustration.

     

    You are comparing a datetime var against an integer and that's what I get when I run your script:

     

    Notice: Object of class DateInterval could not be converted to int in /home/albany/public_html/homejg/test.php on line 10

     

     

    See my signature.

  5. Your question didn't say what was wrong. I assume because you stored the message in a non-existent var that the problem was simply a missing message.

     

    You could turn on php error checking and see if you any other typos that are causing your failure. See my signature.

  6. Interesting... minor syntax changes and it works. Funny I've used the methods employed here bedore but this time there must be something unique about it. Here's my now-working code:

     	$q = "select date_format(a.Match_date,'%m/%d/%y') as Match_date,
    				a.Team_no, a.Player1, a.Player2,
    				b.Last_Name as p1ln, b.First_name as p1fn,
    				c.Last_name as p2ln, c.First_name as p2fn,
    				s1.Player_no as scored1,
    				s2.Player_no as scored2
    			from dart_matches as a
    
    			join voorhees_data.MMS_Members as b
    				on a.Player1 = b.Roster_no
    
    			join voorhees_data.MMS_Members as c
    				on a.Player2 = c.Roster_no
    
    			left outer join dart_match_scores as s1
    				on s1.Player_no = a.Player1 and s1.Match_date = $qdate
    
    			left outer join dart_match_scores as s2
    				on s2.Player_no = a.Player2 and s2.Match_date = $qdate
    		where a.Match_date = $qdate
    		order by a.Team_no";
    
    Thank you very much!
  7. Heres the one that is giving me the problem:

    Array

    (

    [Field] => Match_date

    [Type] => date

    [Null] => NO

    [Key] => PRI

    [Default] =>

    [Extra] =>

    )

     

     

    Array

    (

    [Field] => Team_no

    [Type] => int(11)

    [Null] => NO

    [Key] => PRI

    [Default] =>

    [Extra] =>

    )

     

     

    Array

    (

    [Field] => Player1

    [Type] => varchar(3)

    [Null] => NO

    [Key] =>

    [Default] =>

    [Extra] =>

    )

     

     

    Array

    (

    [Field] => Player2

    [Type] => varchar(3)

    [Null] => NO

    [Key] =>

    [Default] =>

    [Extra] =>

    )

  8. Not my first time doing this but I'm missing something today. Gonna really hate it when you point out my problem here.

     

    My query:

    $q = "select date_format(a.Match_date,'%m/%d/%y') as Match_date,
    	a.Team_no, a.Player1, a.Player2,
    	b.Last_Name as p1ln, b.First_name as p1fn,
    	c.Last_name as p2ln, c.First_name as p2fn
    from dart_matches a,
    	voorhees_data.MMS_Members as b,
    	voorhees_data.MMS_Members as c
    
    left outer join (select Player_no as scored1 from dart_match_scores
    	where Match_date = $qdate) as s
    on a.Player1 = scored1
    
    left outer join (select Player_no as scored2 from dart_match_scores
    	where Match_date = $qdate) as t
    on a.Player2 = scored2
    
    where a.Player1 = b.Roster_no and
    	a.Player2 = c.Roster_no and
    	a.Match_date = $qdate
    
    order by a.Team_no";
    
    
    The error I keep getting is:

     

    Column not found: 1054 Unknown column 'a.Player1' in 'on clause'

     

    The thing is my table structure clearly shows the existence of Player1 in my table and have prefixed every occurrence of it in the query, there are no duplicates and yet this is where it keeps stopping no matter what I do.

     

    Thanks in advance!

  9. Just my $.02 here. As a general practice I name all of my submit buttons as "name='btn'". All my scripts then do this:

     

    if (!isset($_POST['btn'])
    {
    handle the first time into your script here, send your output html and exit.
    }
    $btn = $_POST['btn'];
    if ($btn == 'Return')
    {
    handle my return (to previous caller) button
    header()
    exit()
    }
    if ($btn == 'Do This')
    {
    }
    if ($btn == 'Do That')
    {
    }
    // handle unexpected input.
    echo "Unknown button submitted $btn";
    exit();
    

     

    Obviously, each button has a different label on it and that is how my script knows what to do.

  10. Ok - solved my own problem. Instead of my html calling a routine to validate the input with an onchange call and then handling an Enter key as a Tab with an onkeypress event I consolidate my activities.

     

    With an onkeydown I call my edit routine. In there I check for a tab or enter key. If it's not one I simply ignore it and return. IF the key is an Enter or Tab I perform my editing and if that fails I manage to do either a preventDefault or stopPropagaion and return false. If it passes the tests, I call my routine to handle an Enter as a Tab and then return true.

     

    So now - user can do d/e and hit enter or tab when done. The screen will edit my entry and either keep me on the field or move to the next tabstopped field. Just what I need.

  11. I found out that onblur can be (is really!) a PIA. Just leaving the page causes it to occur and trying to leave the field causes many considerations.

     

    So - any ideas on why my current code won't work? It's a simple d/e screen as I may have said - type in a number and hit enter, and repeat. I just want to edit each number at the time of entry rather than have to go back and look at them all if there is an error.

  12. Apparently my time ran out before I could edit the first post. Please look at this instead.

     

    My input elelments:

    <input type='text' class='sz3' name='pfld11' id='pfld11' value='$pfld11'
    tabindex=3 onchange='return getName(event,this)'
    onkeypress="return moveToNextTabOnEnter(this, event)">
    

     

    And my JS function:

    function getName(e,elem)
    {
    var id = elem.id;
    var key = elem.value;
    var name_fld = 'name' + id.substr(-2,2);
    if (key == '')
    {
    alert("You must provide a Roster #");
    e.preventDefault();
    elem.focus();
    return false;
    }
    if (!membs.hasOwnProperty(key))
    {
    alert("Invalid roster #");
    e.preventDefault();
    elem.focus();
    elem.select();
    return false;
    }
    document.getElementById(name_fld).value = membs[key];
    return true;
    }
    

     

    I think I'm getting the event passed to the function properly now since I no longer get messages in the debugger.

    Still doesn't prevent the tab from happening though.

  13. ok - this borders on a previously posted question but I'll try to be more specific with this one.

     

    I have a d/e form that collects some entries that must be valid. They get checked against an array of valid values and if wrong I must make the user repeat the entry. So - I add an 'onchange' call to each input element tag to call my js edit function. In it I do the check and if it fails I want to place the focuse back on the element and select it and popup an alert box with the problem and then let the user re-enter his value. The problem is I can't keep the focus where I want because it just naturally wants to move to the next tabstop. Here's my code:

     

    <input type='text' class='sz3' name='pfld12' id='pfld12' value='$pfld12'
    tabindex=4 onchange='getName(this)'>
    

     

    And here is the js code:

    function getName(elem)
    {
    var id = elem.id;
    var key = elem.value;
    var name_fld = 'name' + id.substr(-2,2);
    if (key == '')
    {
    alert("You must provide a Roster #");
    elem.focus();
    elem.preventDefault();
    return false;
    }
    if (!membs.hasOwnProperty(key))
    {
    alert("Invalid roster #");
    elem.preventDefault();
    elem.focus();
    elem.select();
    return false;
    }
    document.getElementById(name_fld).value = membs[key];
    return true;
    }
    </script>
    

     

    The js works fine - it's just the end result when the entry is invalid that is my problem.

     

    So - how do I move the focus back to the calling element and avoid the natural tendency to move forward to the next field?

  14. Sounds like you've given up, because I know I wasn't able to give you anything other than some advice.

     

    ok - here is one problem:

    ['confessId'].""

     

    You end your string with two double quotes. Plus if confessed is not numeric you need single quotes around it.

    Turning on php error checking would have told you that.

     

    Again you do this:

     

    SELECT 'X' FROM comments...

     

    Why do you want to collect a set of rows with nothing but an X in them?

×
×
  • 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.