• Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Spunky

  • Rank
  • Birthday 09/29/1989

Previous Fields

  • Languages
    XHTML, CSS, PHP, MYSQL, Javascript, Jquery

Contact Methods

  • Website URL
  • ICQ

Profile Information

  • Gender
  • Location
  1. The issue I am having is with my menu bar. I have recreated it in JS Fiddle. Notice that when you hover over any of the drop-down menu list items (any that are short words or not on 2 lines), the hover color does not spread to the right edge, and I am unable to figure out why. Could somebody take a look at let me know if they have any ideas?
  2. Real simple here: Why does this work.. tr.retired td:not(:nth-child(2)){ background-color:purple; } And this works... tr.retired td:not(:nth-child(3)){ background-color:purple; } But this doesn't work? tr.retired td:not(:nth-child(2)),tr.retired td:not(:nth-child(3)){ background-color:purple; } Fiddle: https://jsfiddle.net/m6z1suyb/ Thanks!
  3. I prefer MySQLi so I will stick with that, thanks. Easier for me to comprehend as I am not a full fledged programmer. I know all about PDO being more versatile. Sure, ofcourse, my bad, I forget that I can easily run the PHP pages alone without the AJAX triggering it. So, the database connection is working. I ran retrieveData.php by itself and the echo $outp is outputting the data from my database as expected, into a JSON object. The issue now seems to lie solely with the AngularJS now so I'll end this topic as is and move onto a different forum area after I have played with this some more. Thanks for all of your helps. I am glad I finally have a working MySQLi connection to use here,for future projects, and to update older projects. You should test your PHP without AJAX first, or at least check the developer console to see exactly what's being returned in the AJAX request.
  4. They do, says string(#) "content" for each one. Plus the error is showing twice in the same alert box, not sure if that means anything or helps any. How, from my above code, could the $password be empty anyway??? Just to cover my bases from pointing fingers I have also tried: <?php $servername = "localhost"; $username = "username_user"; $password = "password"; $dbname = "username_TableName"; var_dump($servername, $username, $password, $dbname); $db_con = new mysqli('localhost','username_user','password','username_TableName'); if($db_con->connect_error){ die("Connection failed: " . $db_con->connect_error); } ?> (also I realize that where I have TableName is actually database name, I accidentally misinterpreted it as TableName, just don't want to correct it now for consistency) I did just notice, however, that data that I am entering to that the PHP is entering into the database with that connection is actually successfully being added. Hmm... thoughts? Also, I should point out that I am actually connecting to the database as soon as my page loads, before I try to enter data via my form which is actually where I am receiving my error. But I am not getting an SQL error when the page loads, just an AngularJS error which is what I am using with AJAX to communicate. here is the PHP that runs from the start: <?php header("Access-Control-Allow-Origin: *"); header("Content-Type: application/json; charset=UTF-8"); require 'databaseConnect.php'; $query='SELECT * FROM TaskTracker'; $db_con->query($query); $outp = ""; $result = $db_con->query($query); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { if($outp != ""){$outp .= ",";} $outp .= '{"desc":"' . $row["DESCRIPTION"] . '",'; $outp .= '"id":"' . $row["ID"] . '",'; $outp .= '"status":"' . $row["STATUS"] . '",'; $outp .= '"reminder":"' . $row["REMINDER"] . '",'; $outp .= '"todayDate":"' . $row["DATESTAMP"] . '"}'; } $outp='{"tasks":['.$outp.']}'; } $result->free(); $db_con->close(); echo($outp); ?> The error I am getting is: angular.js:13920 SyntaxError: Unexpected token s in JSON at position 0 Why it is suddenly having an issue with my JSON I do not know. I removed the headers though and that error went away. No error, but data is no longer being fetched from the database to my html page. Here's the AngularJS: $http.get("retrieveData.php").then(function(response){ $scope.tasks = response.data.tasks; }) I've done what I can to convert my code to MySQLi, but I may be missing certain things.
  5. http://stackoverflow.com/questions/30363045/running-php5-access-denied-to-mysqli-connection-but-success-for-mysql Can't say I haven't tried. Maybe you guys would like to take a crack at it then? Because they couldn't help. So let's stay focused on the important part: <?php $servername = "localhost"; $username = "username_user"; $password = "password"; $dbname = "username_TableName"; $db_con = new mysqli($servername,$username,$password,$dbname); if($db_con->connect_error){ die("Connection failed: " . $db_con->connect_error); } ?> The server specific information matches up exactly. All I did was convert it to MySQLi. The error I get: www.mysite.com says: Access denied for user 'username'@localhost (using password: NO) (yes, there is a strangely large gap between the top text and bottom which is right above the OK button.) Any help?
  6. I am unable to connect to my server when I convert the code to MySQLi and I have not been able to figure out why. But I am not too concerned, I only work on small, personal projects. I already discovered what happens when I add an apostrophe to the string which is it doesn't add the item to the database. So I am unsure how that is what is happening here. The code works, it's just now that I am trying to receive $returnData I am getting the error, however the data is still being added to the database. My code was created with the help of w3schools, maybe about 10 years ago, yes. But no need to insult the code, it works, let's focus on the code that isn't working, please.
  7. So I am posting this issue in this part of the forum due to the SQL error that I am getting, so my best guess is there is an error in my SQL. Basically, what I am doing is using angularjs's $https to communicate with a PHP file. Here is that code: $http.post('enterTask.php', task).then( function(response){ alert(response.data); $scope.tasks.push(task); } ); So, I am sending some data which works fine. Where I am getting the error was when I decided I want to receive back data as well and I am using the alert to test the response. Here is the PHP code: <?php $description = $data->desc; $reminder = $data->reminder; $todayDate = $data->todayDate; $status = $data->status; require 'databaseConnect.php'; $query="INSERT INTO TaskTracker (DATESTAMP,STATUS,DESCRIPTION,REMINDER) VALUES ('$todayDate','$status','$description','$reminder')"; mysql_query($query) or die(mysql_error()); $query="SELECT ID FROM TaskTracker WHERE DESCRIPTION = $description"; $result = @mysql_query($query) or die(mysql_error()); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)){ $returnData = $row["ID"]; } } mysql_close($db_link); echo $returnData; ?> Again, most of this code works just fine, the issue came in when I added everything from the 2nd query and beyond. Here is the error that I am getting when the AJAX runs: You have an error in your SQL syntax: check the manual that corresponds to your MySQL server version for the right syntax to use near 'a 7th test for good luck' at line 1 Part of the data I am sending is here is a 7th test for good luck. And this is stored in $description. Every time this error pops up, it cuts off the first part of it, which I imagine is some clue as to where the error is in the SQL. Any idea? PS: Sorry the PHP code is sloppy, for some reason it appears blank when I post with it in the code box..
  8. 2 typos.. this is what I get for staying up till midnight trying to get this to work... ok so this is what I am getting sent to my email now: Name: [object HTMLParagraphElement]Email: Comment: [object HTMLTextAreaElement] I am not sure why email is still not showing anything. Also I realized I was supposed to add .value to the ends like this: var fn = document.getElementById('fname').value; var ln = document.getElementById('lname').value; var e = document.getElementById('email').value; var p = document.getElementById('phone').value; var m = document.getElementById('message').value; But that didn't do anything. Still, the #1 issue is that the first time I press submit it just reopens the modal the form is in and then it is the second time that it submits. I can try to take it out of the modal and see if that changes anything but either way, I really need it inside the modal. --turns out getting rid of the form fixed this, no need for it I guess anyways since I am not using "onsubmit". EDIT: I am trying to troubleshoot this. When I alert any one of the variables (fn, ln, e, etc) it is undefined and I am not sure why. My JS is located at the bottom of the page before the end body tag so I don't think I need a document ready function but I have tried implementing one which just seems to make it worse. EDIT: Alright this is starting to tick me off.. this is the SIMPLEST JavaScript that I am unable to get to work, I even tried to put it on JsFiddle for a more clear picture and even THAT I can't get to work...https://jsfiddle.net/k1g9dq7w/ -- but anyway this is the code I am currently trying to debug.. simple.. basic.. maybe at this point I should go to the JS forum with this I don't know. ^^^ Ok it seems that if the input is not in a modal, the JS will retrieve the value no problem. I know this is a JS question now, so I am just going to take this to the JS Forums, instead, I have tested this manually by doing: var userdata = "firstname=MyName&lastname=MyLastName&email=email@email.com&phone=123&message=message"; and now this works. So, the code works. I thank you. I will have to figure out my other issue.
  9. HTML: <form id="contact_form"> <p id="fname" class="form_items"> <input type="text" name="fname" id="fname" placeholder="First Name" required /> </p> <p id="lname" class="form_items"> <input type="text" name="lname" id="lname" placeholder="Last Name" required /> </p> <p id="email" class="form_items"> <input type="email" name="email" id="email" placeholder="Email" required /> </p> <p id="phone" class="form_items"> <input type="tel" name="phone" id="phone" placeholder="Telephone" /> </p> <p id="comments" class="form_items"> <textarea rows="4" cols="50" name="message" placeholder="Comments" id="message"></textarea> </p> <p> <button class="submit" type="submit" onclick="submitForm();">Submit</button> </p> <span id="status"></span> </form> JS: function submitForm(){ var xmlhttp = new XMLHttpRequest(); var fn = document.getElementById('fname'); var ln = document.getElementById('lname'); var e = document.getElementById('email'); var p = document.getElementById('phone'); var m = document.getElementById('message'); var userdata = "firstname="+fn+"&lastname="+ln+"$email="+e+"&phone="+p+"&message="+m; xmlhttp.open("POST","submit_form.php",true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState == 4 && xmlhttp.status == 200){ retrieve = xmlhttp.responseText; document.getElementById("status").innerHTML = retrieve; } } xmlhttp.send(userdata); document.getElementById("status").innerHTML = "processing..."; } PHP(submit_form.php): $ToEmail = 'email@email.com'; $EmailSubject = 'Site contact form'; $mailheader = "From: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["first"].""; $MESSAGE_BODY .= "Email: ".$_POST["email"].""; $MESSAGE_BODY .= "Comment: ".nl2br($_POST["message"]).""; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); So now what is happening is that the first time I hit the submit button, my modal closes and reopens, I see "processing..." appear briefly as this happens, but nothing gets sent to email and when the modal reappears there is no status text. When I fill the form out again however, "processing..." shows up briefly then disappears and I have an email. However, this is the contents of the email: Name: Email: Comment: [object HTMLTextAreaElement] There is no updated status text at this time. I assume the modal closing and reopening may be a modal specific issue? Even so, anyone have any ideas why this is happening? But I am sure the modal issue isn't hindering the PHP issue. I am unsure why the data is still not sending properly, or why it is showing what it is for the Comments. Any ideas? Is there suppose to be status text at this time?
  10. I am trying to use AJAX to run some PHP code and I have it working but I am not sure how to send my form information to the PHP code. I have used this PHP code before with a form but that's used something like "onsubmit="thankyou.php" where the PHP page was just like a landing page that the user reviews the information that they sent. Now that I am using AJAX, this is what I have so far: HTML: <form id="contact_form" onsubmit="submitForm();"> <p id="fname" class="form_items"> <input type="text" name="fname" id="fname" placeholder="First Name" required /> </p> <p id="lname" class="form_items"> <input type="text" name="lname" id="lname" placeholder="Last Name" required /> </p> <p id="email" class="form_items"> <input type="email" name="email" id="email" placeholder="Email" required /> </p> <p id="phone" class="form_items"> <input type="tel" name="phone" id="phone" placeholder="Telephone" /> </p> <p id="comments" class="form_items"> <textarea rows="4" cols="50" placeholder="Comments"></textarea> </p> <p> <button class="submit" type="submit">Submit</button> </p> </form> JS: function submitForm(){ var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState == 4 && xmlhttp.status == 200){ retrieve = xmlhttp.responseText; } } xmlhttp.open("POST","submit_form.php"); xmlhttp.send(); } PHP(submit_form.php): $ToEmail = 'email@email.com'; $EmailSubject = 'Site contact form'; $mailheader = "From: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["firstName"].""; $MESSAGE_BODY .= "Email: ".$_POST["email"].""; $MESSAGE_BODY .= "Comment: ".nl2br($_POST["message"]).""; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); I am receiving an email, but everything is blank. I am not seeing any errors in my console or anything. Nothing happens when the form is submitted otherwise. A little background on what I am trying accomplish: I have a contact form appearing in a homemade modal (not bootstrap) where the user can fill it out and then submit without being sent to a landing page.
  11. Oh yea I seen how complicated it was to clone objects the last time I thought I needed a clone. Turns out it was as simple as equalling one object to the other. However, for some reason since this object contains objects with properties or whatever it is doing, I didn't make the connection to the other and didn't realize it is still that simple, just needed the period there. Summary: It does what I need it to do now. Thank you.
  12. ...Or something like that. Here's what I got: myObject = { A:[{ name:"Letter A", text:"I am the letter A" }], B:[{ name:"Letter B", text:"I am the letter B" }]} The catch is I want to push a copy of one of those objects to the end of the object above, but not a complete copy since it will be called different, after the push it should look like this: myObject = { A:[{ name:"Letter A", text:"I am the letter A" }], B:[{ name:"Letter B", text:"I am the letter B" }], C:[{ name:"Letter B", text:"I am the letter B" }]} How would I do this? This is what I came up with so far: lc = myObject.B;alert(lc);myObject.push({ C:lc})alert(myObject.C); lc is indeed a copy of myObject.B, but I don't know how to get it in there, if it's possible. The error I get is that myObject.push is not a function. I just need "C" to output the same results as "B" when dynamically called, so maybe there is a different way set a replica?
  13. *facepalm* should have known about the push thing, I use that elsewhere in my code. I thought they need to be objects since there is the name: and link:. Suppose there's still more I got to learn about arrays. When I console.log($scope.m2Info) it outputs Array [ Object, Object, Object, Object ]. Could you help me understand how name and link and whatever other items I add are stored in this array? You've said I can use console.log to get the structure, is there another way I can set mine up that will give me a clearer picture? I would appreciate it, if I understood this better I will have an easier time with arrays I think. At any rate, this works now. Thank you so much for working with me to get it working.
  14. var holdBuilding = $scope.m1Special.Buildings; var c = 0; $scope.m2Info = {}; $scope.m3Info = {}; $scope.m4Info = {}; $scope.m5Info = {}; $scope.m6Info = {};$scope.create2ndMap = function(){ $scope.m2Info.push=({ name:holdBuilding[c].name, link:holdBuilding[c].link }); alert($scope.m2Info[3].name); c++;}$scope.create3rdMap = function(){ $scope.m3Info.push=({ name:holdBuilding[c].name, link:holdBuilding[c].link }); c++;}$scope.create4thMap = function(){ $scope.m4Info.push=({ name:holdBuilding[c].name, link:holdBuilding[c].link }); c++;}$scope.create5thMap = function(){ $scope.m5Info.push=({ name:holdBuilding[c].name, link:holdBuilding[c].link }); c++;}$scope.create6thMap = function(){ $scope.m6Info.push=({ name:holdBuilding[c].name, link:holdBuilding[c].link }); c++;}angular.forEach(holdBuilding,function(){ if($scope.m1Special.Buildings[c].loc=="Northern"){ $scope.create2ndMap(); } else if($scope.m1Special.Buildings[c].loc=="Central"){ $scope.create3rdMap(); } else if($scope.m1Special.Buildings[c].loc=="Western"){ $scope.create4thMap(); } else if($scope.m1Special.Buildings[c].loc=="Eastern"){ $scope.create5thMap(); } else if($scope.m1Special.Buildings[c].loc=="Southern"){ $scope.create6thMap(); };}); When I console.log($scope.m2Info); This is what I get: Object { push: Object } site.js:654:4Object { push: Object } site.js:654:4Object { push: Object } site.js:654:4Object { push: Object } site.js:654:4
  15. Well this appears to be going well but for some reason it is only displaying the last item for each m#Info. And I cannot figure out how to debug this because when I do one of the following alert($scope.m2Info[0].name);alert($scope.m2Info[c].name); It comes up "undefined" for the entry. I thought that this is how to specify an item in an array??