-
Posts
3,372 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Muddy_Funster
-
OK, I've been encouraged to start and include Ajax in some new site development. Problem is, I've never touched it before so I suck at it, so silly little problems like this bugger me up. I'm trying to get a login form to validate and return xml output that is then displayed in div by the ajax function. I get the "http.responseXML is null" error when I try and do this. I have pretty much copy/paste and then edited code snippets off the net to get this far, and I'm starting to get my head arround what does what and where it does it, but I can't find what the problem is with this. the script code is: // JavaScript AJAX Document var http = createRequestObject(); function createRequestObject() { // find the correct xmlHTTP, works with IE, FF and Opera var xmlhttp; try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { xmlhttp=null; } } if(!xmlhttp&&typeof XMLHttpRequest!="undefined") { xmlhttp=new XMLHttpRequest(); } return xmlhttp; } function GetID(uName, uPass){ var name = uName; var pass = uPass; if(name.length >0 && pass.length >0) { name=escape(name); pass=escape(pass); try{ http.open("GET", "inc/login.php?name="+name+"&password="+pass, true); http.setRequestHeader('Content-Type', "text/xml"); http.onreadystatechange = handleResponse; http.send(null); } catch(e){ // caught an error alert('Request send failed.'); } finally{} } else { alert("please complete both fields"); } } function handleResponse() { try{ if((http.readyState < 4)||(http.status != 200)){ var ajaxDisplay = document.getElementById('main'); ajaxDisplay.innerHTML = '<BR><BR><center><img src="./img/loading6.gif" alt="Loading..."><BR>Loading...</center>'; } if((http.readyState == 4)&&(http.status == 200)){ var response = http.responseXML.documentElement; var n = response.getElementsByTagName('message')[0].firstChild.nodeValue; var e = response.getElementsByTagName('status')[0].firstChild.nodeValue; var r = response.getElementsByTagName('contnent')[0].firstChild.nodeValue; // write out response document.getElementById("main").innerHTML = r; alert(n); } } catch(e){ // caught an error alert('Response failed. >>'+e); } finally{} } the login.php file (still commented from when I was checking it in browser) <?php /* @SESSION_START(); require_once './connection.php'; $name = mysql_real_escape_string($_GET['name']); $pass = mysql_real_escape_string($_GET['password']); $logSQL = "SELECT branchNo FROM branch WHERE authLogin ='$name' AND branchPass = '$pass'"; $logCHK = mysql_query($logSQL); if(mysql_num_rows($logCHK) <> 1 ){ */ print "<?xml version='1.0' encoding='ISO-8859-1'?> <xml> <status>F</status> <message>Either your login ID or password are incorect, please try again</message> <content><?php require_once 'first_check.php'; ?></content> </xml>"; /* } else{ $logRES = mysql_fetch_array($logCHK); echo "Login Successfull"; $_SESSION['id'] = $logRES['branchNo']; print "<?xml version='1.0' encoding='ISO-8859-1'?> <xml> <status>Y</status> <message>Loggin Succsessful</message> <content><?php require_once 'first_check.php'; ?></content> </xml>"; }*/ ?> and the page with the login form: <?php if (!isset($_SESSION['id'])){ ?> <div id="login"> <form action="#" name ="login" method="post"> <center>Login:<br /> Login ID: <input type="text" name="name" id="name" value=""><br><br> Password: <input type="password" name="password" id="password" value=""><br> <input type="button" alt="Login" value="Login" onclick="GetID(login.name.value, login.password.value)"> </center> </form> </div> </p>Welcome to the new McConechy's Intranet Site. Updates and construction are still ongoing at the moment, with only some of the site operational.</p> <p> To Access most feetures you are requred to log in. this is both to maintain security, and also to identify you on the site.</p> <?php } else{ print " You are Logged In. Updates and construction are still ongoing at the moment, with only some of the site operational. Please use the buttons on the left to navigate. "; } ?> I have checked the generated XML and it's fine as far as any validators are concerned, I also checked the link in firebug when the error comes up and it contains the xml as it should be, with nothing additional/erronious that I can see. I have the type set to text/xml (as you can see in the code) and have checked the login.php directly in the browser and it is producing the data as it should. This is still very early development so it's a good bit messy, that will be deat with in due course, but I sure would appreciate some assistance on this one.
-
while($obj = mysql_query($rs)) This doesn't produce the result set data, you need to do a mysql_fetch_assoc() or mysql_fetch_array() to get back what you are looking for: $rs_return = mysql_query($rs); while($obj = mysql_fetch_array($rs_return)) { $arr[0] = $obj['id']; $arr[1] = $obj['title']; $arr[2] = $obj['author']; $arr[3] = $obj['date']; $arr[4] = $obj['imageUrl']; $arr[5] = $obj['text']; } You could use an array_push if you preffer.
-
at the end
-
Finding data in rows and data in combined rows
Muddy_Funster replied to cliftonbazaar's topic in MySQL Help
I'm not getting it, what do you want to do that you are not already doing? -
Of course it does, you have no WHERE statement in your UPDATE to specify that you only want a single record updated.
-
Something wrong with my if statement
Muddy_Funster replied to cerberus478's topic in PHP Coding Help
What's the actual problem?!? -
learn how to join, and maybe learn how to write SQL while you're at it: your error message relates to the fact that you have wraped the first section of the select within parenthesis and so terminate the select prematurely, not that it would work if you removed the parenthesis either. Really, that query is a mess...It should look something more like: SELECT tbl_question.question_id, question, description, user_id, category_id, question_slug, tbl_question.date AS q_date, tbl_answer.answer_id, user_id, answer, tbl_answer.date AS a_date, rating_id, point FROM tbl_rating LEFT JOIN tbl_answers ON (tbl_rating.answer_id = tbl_answers.answer_id) LEFT JOIN tbl_question ON (tbl_question.question_id = tbl_answer.question_id) WHERE tbl_question.question_slug = "$question_slug" ORDER BY tbl_answers.answer_id
-
yeah, gonna need to see the structure & data, It looks to me like subqueries might be the way to go for this one instead of strate joins.
-
Loop within loop/query within query best practices
Muddy_Funster replied to msaz87's topic in MySQL Help
"inputted"....Really? :-\ I have only come accross a single instance where I absoloutly had to run a SELECT loop from within a SELECT loop, and that was when performing a cross refference lookup between MySQL and MS SQL Server. Neither of the scenarios that you have posted requre nested loops. Generaly, if you are working on the same server for all your queries then your likelyhood of requering nested loops is slim. Avoid the practice where and when you can. -
Likely problems would be (in order of likelyhood): poor query structure bad/no normalisation network bandwidth restrictions server hardware not up to task As for running MySQL on multiple Disks and or server - hell yeah you can, google "MySQL replication and load balancing"
-
I'm pretty confident that whatever you do during the select has no bearing on the field used in the group by....
-
Finding data in rows and data in combined rows
Muddy_Funster replied to cliftonbazaar's topic in MySQL Help
You're doing that already...arn't you? your total runs is telling you what the combined score over both innings is. -
Without going into why you have NULL values in an ID field, could you post up your actual table structures and sample data sets?
-
You never played AD&D then ....ahh, the good old days.
-
You've done it again. Delete the line <?php do {
-
your using the wrong connector. here - have a look at this : http://msdn.microsoft.com/en-us/library/cc793139%28v=sql.90%29.aspx
-
<?php do{ here, try this: <?php echo '<img border="0" src="http://www.hiringinhilo.com/Hilo-Jobs/Hilo-Logo/job-search-results-top.gif">'; echo '<table width="500">'; echo'<tr><th>Job Title</th><th>Date Posted</th><th>State</th><th>Job Type</th></tr>'; while ($rsjobs=mysql_fetch_assoc($jobs_query)){ echo '<tr><td>'; echo '<td><a href="http://www.hiringinhilo.com/Hilo-Jobs/Job-Search-Form/Getting-Data-From-Database/Job-Details/Job-Details.php?id=<'.$rsjobs['id'].' target="new">'.$rsjobs['JobTitle'].'</a></td>'; $date = date("m/d/Y",strtotime($rsjobs['PostedOnDate'])); echo '<td>'.$date.'</td>'; echo '<td>'.$rsjobs['State'].'</td>'; echo '<td>'.$rsjobs['JobType'].'</td>'; echo '</tr>'; } echo '</table>'; I have to assume you have assigned the value to $job_query outwith the code you have provided.
-
save them as csv and use LOAD DATA INFILE - see http://dev.mysql.com/doc/refman/5.1/en/load-data.html
-
Storing config data in file or database?
Muddy_Funster replied to etrader's topic in PHP Coding Help
Wordpress also loads that data into a DEFINE list at login, so the data is stored in the database for consistancy between sessions, as well as security and integrity and only queried once per login. -
use get or post to pass the variable from page one to page two - which you would clearly know if you did indeed know "these GET and POST methods". //page1.php <?php $var ="Hello World" header("location : page2.php?var=$var"); ?> //page2.php <?php $var=$_GET['var']; echo $var; ?>
-
:facewall:
-
and what exactly does "it doesn't like" meen? perhaps missing some single quotes here? isset($_POST[noIdentity][.php]