-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
the problem is, as sasa said, the $passed variable is local to the stuff() function, so your levelup() function can't access it. If you want levelup to have access to the $Passed variable, you must return the value from the stuff function, as sasa said, and use that returned value in the levelup function. so in your stuff function change echo $passed; to return $passed; and when you call the levelup function do something like what sasa posted. hope that helps!
-
yeah thats fine, but the problem is you aren't adding the location variable to your email anywhere. you are going to have to alter your email function and add it somewhere. Exactly what is the location field? And where do you want it to be in the email?
-
[SOLVED] getting database count from mysql query
mikesta707 replied to heldenbrau's topic in PHP Coding Help
well it doesn't get incremented because in your code if ($count==0){ $count++; } this never runs because count is not zero. if you want to always increment the count function, then remove the if statement and simply have $count++ -
[SOLVED] getting database count from mysql query
mikesta707 replied to heldenbrau's topic in PHP Coding Help
a much easier way to get the count of rows in your table is to use the mysqli_num_rows function this will get your count: $sql = "SELECT * FROM cases"; $result = $mysqli->query($sql); $count = mysqli_num_rows($result) EDIT: syntax error and also link to function: http://us2.php.net/manual/en/mysqli-result.num-rows.php -
//this: stuff(hq,$dbc); //should be stuff($hq,$dbc);
-
[SOLVED] Learning PHP - cant get log in system to work.
mikesta707 replied to benjipie's topic in PHP Coding Help
I'm not to familiar with mysqli functions, but I was reading up on the PHP.net page on mysqli_query: http://us.php.net/manual/en/mysqli.query.php maybe try instead of $result = $db_conn->query($query); use $result = $db_conn->query($query, MYSQLI_USE_RESULT); Can't guarantee that will do anything, but hope that helps -
you never add the location variable to your header, or message body, or really anything having to do with the email. If you want the location to be added to the message body, do something like $body .= "Location: $location"; I haven't done php mail in a while, so i'm not sure if there is a special place Location is supposed to go, but I think thats right. Hope that helps! oh and btw, wrap your code with code or php tags IE: "<php>code</php> or <code>code</code>" but instead of < and > characters replace them with [ and ] characters respectively
-
I saw one error that may be the cause of your issue. the following code $name = stripslashes(isset($_POST['txtName'])); $email = stripslashes(isset($_POST['txtEmail'])); $message = stripslashes(isset($_POST['txtMessage'])); sets the variables to boolean values (or rather, to values returned from the isset() function. Since (i'm assuming) the post variables are already set, the isset function will return +1. Conversely, if they aren't set, it will return -1. you can fix that by the following: if (isset($_POST['txtName'])){ $name = stripslashes($_POST['txtName']); } //etc for the other values try that. Hope that helps!
-
[SOLVED] Custom Javascript Array sort not sorting correctly
mikesta707 replied to mikesta707's topic in Javascript Help
never mind, I figured it out. For those who are curious the reason goes as follows: Using my method, it is sorting as a numeric string, not as a quantifiable number, and since the value "100" starts with 1, it goes below every other number except for zero. To fix this, I added a preceding "0" to any number of two digits or lower. the fixed function looks like the following: function value_sort(a,b) { a = a[5]; b = b[5]; if (a.length < 3){ pre = "0"; a = pre + a; } if (b.length < 3){ pre = "0"; b = pre + b; } return a == b ? 0 : (a > b ? -1 : 1); } -
Ok, I have a 2-d array, and I am trying to sort it numerically by the 6th column (or array[5]). The array is something like array = ("Stuff", "Something else" "other stuff", 95, 95, 100); The 6th column is the percent of quotient of the 4th and 5th column times 100 (basically a percent) So the sorting code I have looks like the following function value_sort(a,b) { a = a[5]; b = b[5]; return a == b ? 0 : (a > b ? -1 : 1) } full_array.sort(value_sort) It does sort it somewhat, but When it sorts, anything below 100% (IE 99 % 98% etc.) is sorted correctly, but 100% values are below everything but 0% values. so if the array's 6th column looks like the following 100 99 98 97 96 100 100 100 5 6 7 8 0 0 0 then the sorted array will look like: 99 98 97 96 8 7 6 5 100 100 100 100 0 0 0 I don't really understand why. Anyone got any ideas?
-
yeah your going about this in a somewhat screwy way. The way I would do what your trying to do is build the table with php echo commands, and put all the different td id's into an array, and iterate through that array. something along the lines of $ids = array("tl", "ml", "bl"); foreach($ids as $move){ if($move == "TL"){ $linky = 'wland.php?action=upleft'; } if($move == "TR"){ $linky = 'wland.php?action=upright'; } if($move == "BL"){ $linky = 'wland.php?action=downleft'; } if($move == "BR"){ $linky = 'wland.php?action=downright'; } if($move == "TM"){ $linky = 'wland.php?action=up'; } if($move == "BM"){ $linky = 'wland.php?action=down'; } if($move == "MR"){ $linky = 'wland.php?action=right'; } if($move == "MM"){ $linky = 'wland.php'; } if($move == "ML"){ $linky = 'wland.php?action=down'; } $onclick = 'onclick="window.location.href=\''.$linky.'\'"'; $link = $onclick; echo "<td id=\"$move\" $link >"; //the other stuff } I dont know why you have the $link variable. You can just use the $onclick variable. hope that helps!
-
try document.getElementById('VpcCanvas').style.backgroundImage="url(responseText2)"; //this is blank2.png remember when altering the styles of something you have to set the specific style attribute with correct CSS syntax
-
Getting mouse coordinates within a canvas
mikesta707 replied to phpknight's topic in Javascript Help
I believe he wants you to post your code. I laughed a little on the inside -
what does your current code look like?
-
Using Variables from different code blocks
mikesta707 replied to mikesta707's topic in Javascript Help
yeah sure, but there isn't much else, just building my array from a data base. I am afraid I have a different problem than I first thought. Let me explain what I am trying to do first, bear with me. I take data from a database, and populate a 2d PHP array with it. via the following: $tot_perc = 0; $count = 0; $full_array = null; while (OCIFetchInto($do, $results, OCI_ASSOC)){ $r = $results; $threshold = 70; $style = ""; if ($r[COUNT_ALL] == 0){ $percent = 0; $percent = number_format($percent, 0); } else { $percent = $r[COUNT_POPULATED] / $r[COUNT_ALL]; $percent *= 100; $percent = number_format($percent, 0); } if ($percent < $threshold){ $style = "style='background-color:#FF0000'"; } else if ($percent > $treshold && $percent <= 89){ $style = "style='background-color:#FFFF00'"; } else if ($percent > 89){ $style = "style='background-color:#00FF00'"; } $temp_array = array($r[ORG_ID], $r[TABLE_NAME], $r[FIELD_NAME], $r[COUNT_ALL], $r[COUNT_POPULATED], $percent, $style); if ($full_array == null){ $full_array = array($temp_array); } else { array_push($full_array, $temp_array); } $tot_perc += $percent; $count++; } the query and execution of the query has been left out, but its just a simple oracle database query that does indeed work and get the correct information. What I want to do is create a button that populates a table I have with the information from the array. Since I can only build the array with PHP, and can only dynamically add stuff to a table with javascript, I am faced with the issue of having both of them talk to each other. I am able to build a 2-d javascript array correctly, with the correct data with the following code: echo "<script type=\"text/javascript\">"; echo "full_array = new Array();\n"; for ($i = 0; $i < count($full_array); $i++){ echo "full_array[$i] = new Array(7);\n"; echo "full_array[$i][0] = " . "\"" . $full_array[$i][0] . "\"" . ";\n"; echo "full_array[$i][1] = " . "\"" . $full_array[$i][1] . "\"" . ";\n"; echo "full_array[$i][2] = " . "\"" . $full_array[$i][2] . "\"" . ";\n"; echo "full_array[$i][3] = " . "\"" . $full_array[$i][3] . "\"" . ";\n"; echo "full_array[$i][4] = " . "\"" . $full_array[$i][4] . "\"" . ";\n"; echo "full_array[$i][5] = " . "\"" . $full_array[$i][5] . "\"" . ";\n"; echo "full_array[$i][6] = " . "\"" . $full_array[$i][6] . "\"" . ";\n"; } echo "</script>"; What I am having trouble with is a function that takes that array, and creates the table data. Currently my function looks like the following: function fill_table(){ var k = 1; string = "" for(i = 0; i < full_array.length; i++){ string += "<tr>"; string += "<td>" + (i + 1) + "</td>"; string += "<td>"; string += full_array[i][0]; string += "</td>"; string += "<td>"; string += full_array[i][1]; string += "</td>"; string += "<td>"; string += full_array[i][2]; string += "</td>"; string += "<td>"; string += full_array[i][3]; string += "</td>"; string += "<td>"; string += full_array[i][4]; string += "</td>"; string += "<td full_array[i][6]>"; string += full_array[i][5] + "%"; string += "</td>"; string += "</tr>"; k++; } div = document.getElementById("data");//the id of the div tag with the table div.innerHTML = div.innerHTML + string;//SHOULD fill out the table. does not } when the page begins, the following is already in the "data" div tag (i create it with php, I'm not sure why i didn't just write straight html, but its already working so...) echo "<div id=\"data\">"; echo "<table border='1'>"; echo "<tr>"; echo "<td>Row #</td>"; echo "<td>ORG_ID</td>"; echo "<td>"; echo "TABLE_NAME"; echo "</td>"; echo "<td>"; echo "FIELD_NAME"; echo "</td>"; echo "<td>"; echo "COUNT_ALL"; echo "</td>"; echo "<td>"; echo "COUNT_POPULATED"; echo "</td>"; echo "<td>"; echo "Percentage"; echo "</td>"; echo "</tr>"; What currently happens, is that the function does write the information from the array into the div tag, but it doesn't continue the table. the output looks like: [column name][column][column][etc][etc][etc] a string of the data from the array, not seperated into columns. just static text that has a rather strange format I am not sure what the problem is with my javascript or PHP. Edit: Note, When I do a call to the JS alert function, and alert the string variable from the fill_table() function, it does output the correct information, with the HTML tags and all. Is there a problem with the innerHTML method that I am missing? That seems to be the only part that doesn't work -
Using Variables from different code blocks
mikesta707 replied to mikesta707's topic in Javascript Help
well, my JS array and PHP array are the same size. They are the same exact array actually, and thats how I iterate through my PHP array so I can assign the correct values to my JS array. I'm assuming this is wrong, How should it be done. I've done a few google searches on this, and most of the links I have found say to do it this way. -
I was wondering if it was possible to use variables defined in different code blocks. IE would the following work: <script> my_var = "Test Data"; </script> //some html or something <script> document.write(my_var); </script> obviously my implementation is far more complicated. I use PHP and echo javascript so I can build a javascript array with the same data as a php array. The code that does this looks like this: [code=php:0] echo "<script type=\"text/javascript\">"; echo "full_array = new Array();\n"; echo "full_array[0] = new Array(7);\n"; for ($i = 0; $i < count($full_array); $i++){ echo "full_array[$i][0] = " . $full_array[$i][0] . ";\n"; echo "full_array[$i][1] = " . $full_array[$i][1] . ";\n"; echo "full_array[$i][2] = " . $full_array[$i][2] . ";\n"; echo "full_array[$i][3] = " . $full_array[$i][3] . ";\n"; echo "full_array[$i][4] = " . $full_array[$i][4] . ";\n"; echo "full_array[$i][5] = " . $full_array[$i][5] . ";\n"; echo "full_array[$i][6] = " . $full_array[$i][6] . ";\n"; } echo "</script>"; when I try to use the full_array var in one of my functions, it shows as undefined. Am I doing this right? Is my Javascript code wrong? I am far more adept at PHP than Javascript, so I think I am doing something stupidly wrong with javascript. Anyone have any ideas?[/code]
-
[SOLVED] Outputting a php array in Javascript
mikesta707 replied to mikesta707's topic in PHP Coding Help
Yeah, something like this is what I was thinking. I think I got it working. Thanks! -
Hello all. What I am trying to do is echo a 2-D php variable in javascript. So far, I have something like this element.innerHTML = <?php echo count($full_array); ?>; for (i = 0; i < <?php echo count($full_array) ?>; i++){ string += "show:" + "<?php echo $full_array[0][5]; ?>" + "<br />"; } and this works perfectly fine. What I want to do is iterate through the entire PHP array, and output all the different entries. Normally, in php you just do something like for($i = 0; $i < count($array); $i++){ //do whatever like: echo $array[$i]; } or use the foreach loop. My problem is that since I'm looping through in Javascript, I can't use $i variable, and I need another way of telling PhP which specific entry in the array I want. I'm sure there is a simple solution to this, but I can't seem to figure it out. Anyone got any insight? using php 5.2 btw
-
post some code? post what you expect to happen and what is happening? post something for god's sakes?
-
this assumes everyone of his links has the target attribute set _blank, has the target attribute as the last set attribute, that it has double quotes, has no space between it and the ">" character, etc. Regex would be a lot more appliable to different types of links with different attributes
-
Ah yes, thats probably the easier way to do it. I never liked doing it that way, for various irrational reasons. Also, here is a good tutorial on regex http://www.phpro.org/tutorials/Introduction-to-PHP-Regex.html
-
well first of all, that code is rife with syntax errors. when you have double quotes in a string, you need to escape them, IE $string = "quotes\" and quotes\" and quotes\""; Additionally, explode will leave with you 2 chucks <a rel="nofollow" href="http://www.mysite.com/?d=9FDS32S" target="_blank" and http://www.mysite.com/?d=9FDS32S</a I would suggest using a regex function to extract whats between the tags. That would probably be the easiest way to get just the URL
-
Do you have a specific validation method or do you just want to cleanse the input before you put in the database to protect against SQL injection? here is an example function http://www.roscripts.com/Protect_against_SQL_Injection-72.html
-
[SOLVED] mysql_query INSERT not working
mikesta707 replied to php_beginner_83's topic in PHP Coding Help
Edit: nevermind again, It was a simple syntax error, just not the one I thought try: mysql_query("INSERT INTO place (ID, Name) VALUES ($newID, $_POST[name])") or die("Error, Insert Failed: ".mysql_error()); you are missing a closing ")" character in the query. also, as some people said, you can set up your table to auto increment your id field (IDK if you set up your tables manually, or use something like phpmyadmin, but either way you can pretty easily) in the future, when dealing with sql, it helps to output the mysql error ie query or die("Mysql Error: " . mysql_error());