Jump to content

mjcoco

Members
  • Posts

    26
  • Joined

  • Last visited

    Never

Posts posted by mjcoco

  1. I know this isnt the best question or anything but basically i need help with passing a second variable.  As in www.example.com?id=32  and seperately have it to where it displays a new list of links and when they click on that it will add in &cat_id=14 etc

     

    Basically its like narrowing a search click the first link that narrows it down with the id's=32 then then on the next page it will have new links to narrow it down even further.  I have it to where it does the first, but im not sure how to do the latter (&cat_id=14)

     

    Thanks

  2. I never really learned how to properly join tables, i did find a way to hack together some sql for it to work together anyway.  Here is what i have.

     

    	$q = "SELECT * FROM Homework h, University s, department d, course c, professors p where h.Universe = s.id AND h.Depart = d.dept_id 
    			AND h.Cour = c.course_id AND h.Prof = p.prof_id";

     

    Which will produce the correct information needed however when i run

     

    	$result = mysql_query($q,$conn);
    while ($a = mysql_fetch_array($result))

     

    It runs twice.   My main question is the first code...

    I know i should use a join however im not sure exactly how it goes.  Something like this?  ???

     

    SELECT * FROM Homework

    INNER JOIN University WHERE Univers=id

    INNER JOIN department WHERE Depart = depat_id

     

     

    Second could my while statement be running twice because i dont have properly joined tables?  Or is there an error in the query itself?

     

    Thanks,

  3. <tr>
    <td width="78">Username</td>
    <td width="6">:</td>
    <td width="294"><input name="login" type="text" id="login"></td>
    </tr>
    <tr>
    <td>Password</td>
    <td>:</td>
    <td><input name="password" type="text" id="password"></td>
    </tr>
    <tr>
    <td width="5%" > <input type="submit" name="login" value="login"></td>
    <td width="5%" > <input type="button" value="register" onclick="window.location.href='registrationbackup.php';"></td>
    
    </tr>

     

    first maybe change the login for each name, textfield and submit.   Since you have login for the input for text and for the submit.

     

    second im not sure that

    onclick="window.location.href='registrationbackup.php';"

    is necessary, you can probably just use

    onclick="registrationbackup.php"

      Also try print 'alert($myusername);'; see what it gives you, if its giving you what you typed and whats in your database, its you query

  4. Im passing about 5 variables though post.  Its sloppy, but im just trying to get it to work before i go back and make it run smooth.  Anyway here is some code im having problems with.. Not sure if i need to post more of the code, but here is where, i believe the problem lies...

     

    			  	<form id = "myform" enctype="multipart/form-data" action="upload_file.php" method="POST"> 
    			<table width="527" height="110" border="0" align="left" cellpadding="0" cellspacing="0">
                    <tr><td width="172" height="32">University:</td>
    			<td width="262"><select name="Univers" onChange="getDepart(this.value)">
    			<?php displayUniversity();?> 
            		</select></td>
                    </tr>
                                                                
                    <tr><td width="172" height="32">Department:</td>               
    			<td width="262"><div id="departdiv"><select name="Department" id="Department">
    			<option>Select University First</option>
            		</select></div>      			</td>
                    </tr>   

     

     

     

    My sql statement

     

    $de =  $_POST['Department'];	
    $q = "select * from department WHERE dept_id = $de";
    $result = mysql_query($q,$conn);
    $a = mysql_fetch_array($result);							

     

     

    Getting the Warning

    mysql_fetch_array(): supplied argument is not a valid MySQL result resource

     

     

    Which of course means that it is not getting a result in the fetch.  I understand that.  Here is my problem.  I am passing 3 other variables which all execute perfect.  This one on the otherhand is not.  I cant figure out what the problem is or where it is at.  The Univers _POST works great.  However when i try it with the Department it does not run.  Its partial code.  I have it running with ajax (along with the other 2 variables that work fine) which populates the Department dropdown box.

     

    Any insight would be helpful.

     

  5. while($row=mysql_fetch_array($result))
    {
    $rand="{$row['random1']}";
    }

     

    This is an example of a scope.  if you put a variable inside a while loop for example it will only stay there.

  6. I was reciving this error before.  It has to do with the way you are accessing your database from the site.  Like Xurion said it deoends on the provider some you can just type in the table name some you have to do domain_table name etc.

  7. The easiest way around that is to send a new randomly generated password to the users email address and force them on first relogin to change their password.  Once they have changed their password re-encrypt and start the process all over. (if they forget thier password again).  Im sure there is a way around it, i use $md5pass, and thats the only way i know how to get around it.

  8. Ok im having trouble figuring this out.  Here is my problem, say you have a table of Professors and a table of Courses

     

    Courses ex.  COSC CPSC MATH HIST

    Professor ex. JOHN HARRY DAVE JIM

     

    JOHN can teach COSC and CPSC

    HARRY may only teach math

     

    etc... you get the point.  Im having trouble with the logic.  Im trying to figure out without having to make a column for every course ( COSC CPSC ) to be able to link Professors to many courses as in the JOHN example.

     

    Right now i have it to where they can only be associated with 1 course.  For example 1 = COSC

    cour_id    prof
      1        JOHN

     

    But what im looking to do is for JOHN to be associated with COSC AND CPSC

  9. Not to be a pain, but this is not a javascript board, it is a PHP board.

     

    Right well my problem is within my php page itself... I guess I should have mentioned that before...

     

     

    <form action="insertfunc.php" method="post">
    			<table width="446" height="110" border="0" align="left" cellpadding="20" cellspacing="20">
                    <tr><td width="172" height="32">TAG:</td>
    			<td width="262"><select name="Un" size="1" id="Un" onchange="GetSecti(str)">
          			<?php displayUn();?> 
          			</select>

     

     

    The php displayUn() calls a php page that inserts the options from a MySQL database and values as the same thing and inserts it into a listbox.  In this one i added back the GetSecti(str) to test a few things.

     

    Or maybe this still needs to be moved?  ???

  10. I have a tag in the page where the drop down lists are for the .js file

     

    <script src="selected.js" type="text/javascript"></script>

     

    and in the dropdown i have onchange="GetSecti()">

     

    However in the GetSecti i had GetSecti(this.value)

    But i was getting errors saying

    Error: Object Expected

     

    If i took them out i recieved the same error.  My .js file is as follows

     

    // JavaScript Document
    var xmlHttpfunction GetSecti()
    { 
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
    alert ("Browser does not support HTTP Request")
    return
    }
    var url="getselected.php"
    url=url+"?q="+str
    url=url+"&sid="+Math.random()
    xmlHttp.onreadystatechange=stateChanged 
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
    }function stateChanged() 
    { 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 
    document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
    } 
    }function GetXmlHttpObject()
    {
    var xmlHttp=null;
    try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
    //Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
    return xmlHttp;
    }

     

    which of course then calls the get getselected.php file.  I had an alert in there which of course was not getting called since it seems as if the .js file is not being called.  Any help on this at all?

     

    Thanks

    Michael

  11. Im trying to auto populate a list box with information that is in the database.  The problem im running into is that im only displaying 1 of the elements not all of them.

     

    <?
    session_start(); 
    include("database.php");
    
    function displayProf()
    {
    global $conn;
    
    $q = "select * from members";
    $result = mysql_query($q,$conn);
    $row = mysql_fetch_array($result);
    $coun = mysql_num_rows( $result );
    for($i = 0; $i < $coun; $i++)
    {
    echo $row[4];
    
    
    
    }
    
    }
    ?>
    
    

     

     

    of course i realize this isnt putting anything into the combo box but i want it to display all the info before i put it in there.

  12. Ok, i figured it out... hostmonster has it set up odd.  Anyway, i just needed to set the account_username and account_checklog

     

    oops anyway.

     

    I do have another question.  I wanted to display the login form only when a user is not logged in.  i know i need to use session_start() but im not sure exactly how to use it.  Any help at all?

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