PHP - Weird Issue.
Hey guys, how are you. I have an odd problem and I am not sure what is causing it. I recently finished my form system, with PHP validation that sends the inputted information via email. Now, everything is working fine on my end with absolutely no issues, but it is not working on any other computers, even though my computer is in no way hosting the files.
Now, the issue other computers are getting is when the form is filled out it doesn't redirect to the success page, it redirects back to the form page with nothing filled out and it doesn't display the errors on the page. Any idea on what might be causing this? Again, EVERYTHING works flawlessly on my end, that being, the display of any errors, the proper redirect, everything. Thanks!!! Similar TutorialsThere's probably an obvious reason but I can't seem to find it... I start with the $_POST array, received from a form: Code: [Select] array(9) { ["Name"]=> string(3) "KTN" ["SQLServer"]=> string(24) "10.6.11.20\VSQLI028,1433" ["Username"]=> string(2) "GF" ["Password"]=> string(2) "GF" ["MasterDB"]=> string(11) "GFMaster_KN" ["Version"]=> string(3) "4.9" ["Prod"]=> string(1) "1" ["Monitored"]=> string(1) "0" ["button"]=> string(38) "updateColumnName=EnvironmentID;Value=1" } I get the button value from the array, and unset the button array value. Code: [Select] function load_POST($name) { //returns value and removes it from $_POST array. returns NULL if not existing. $debug = 0; if ( $debug == 1 ) { $backtrace = backtrace(); echo __FUNCTION__."()"; echo " <i>called by ".basename($backtrace[1]['file'])."</i><br/>\n"; } $post = NULL; if( array_key_exists($name, $_POST) ) { $post = urldecode($_POST[$name]); if ( $debug == 1 ) { echo "post $name, value: $post<br/>\n"; } } else { if ( $debug == 1 ) { echo "post $name: doesn't exist<br/>\n"; } } unset($_POST[$name]); return $post; } $_POST is now: Code: [Select] array(8) { ["Name"]=> string(3) "KTN" ["SQLServer"]=> string(24) "10.6.11.20\VSQLI028,1433" ["Username"]=> string(2) "GF" ["Password"]=> string(2) "GF" ["MasterDB"]=> string(11) "GFMaster_KN" ["Version"]=> string(3) "4.9" ["Prod"]=> string(1) "1" ["Monitored"]=> string(1) "0" } Then I create the object to assign the values to: Code: [Select] object(Environment)#1 (9) { ["EnvironmentID"]=> NULL ["Name"]=> NULL ["SQLServer"]=> NULL ["Username"]=> NULL ["Password"]=> NULL ["MasterDB"]=> NULL ["Version"]=> NULL ["Prod"]=> int(0) ["Monitored"]=> int(0) } So far so good Then, for each remaining $_POST value, I update the Object accordingly: First one, parametername: Name, parameter: KTN Code: [Select] object(Environment)#1 (10) { ["EnvironmentID"]=> NULL ["Name"]=> string(3) "KTN" ["SQLServer"]=> NULL ["Username"]=> NULL ["Password"]=> NULL ["MasterDB"]=> NULL ["Version"]=> NULL ["Prod"]=> int(0) ["Monitored"]=> int(0) ["ColumnName=EnvironmentID;Value=1"]=> object(stdClass)#3 (1) { ["ColumnName"]=> string(1) "1" } } And there we have the problem, for some reason the button value is added to the object somehow... Any ideas? Thanks in advance! Dear all, I updated my versions of php/MySQL and OS to Windows 7 Professional and weird "Warnings and Notices:" started popping up. E.g. Code: [Select] "Notice: Undefined index: page in C:\Server\htdocs\domain\index.php on line 25 " Code: [Select] Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for '-4.0/DST' instead in C:\Server\htdocs\domain\index.php on line 12 " I don't know what is going on. Unless I enter these following functions (error_reporting(0);, session_start() with their parameters these warnings display. Can anyone offer any advice? Any assistance is appreciated. this works Code: [Select] <form action="" method="post"> <input name="DepartureDate" type="text"> <input name="" type="submit"></form> <?php $DepartureDate=$_POST['DepartureDate']; echo $DepartureDate = stripslashes($DepartureDate); // sql inject clean $regex = "/^[a-z]+$/"; if (!preg_match($regex, $DepartureDate)){ echo 'CAPS BABY!';} else {echo 'OK!';} ?> this doesnt Code: [Select] if (!preg_match($regex, $DepartureDate)) { mail($to, $subject, $message, $headers); echo $url_success = "confirmation.php"; //echo("<meta http-equiv = refresh content=0;url=".$url_success.">"); } else { exit(); } Okay, so basically my news-like site is supposed to print out article data saved in the database. It does that quite alright, except on the 3rd article (number 2 in SQL rows or columns. whichever it is. I have my counter subtract 1 from the start article to compensate for MySQL) My code: Code: [Select] <?php print "<div class = 'menu' align='center'>Newest Stories</div>"; if (isset($_REQUEST['mstart'])) { $start=$_REQUEST['mstart']; } else { $start=1; } if ($start) { $start=1; } $start--; $end=$start+5; $stories = mysql_query("SELECT * FROM stories ORDER BY id DESC LIMIT $start, $end") or die(mysql_error()); $num = mysql_num_rows($stories); $start++; if ($num > 0) { if ($num<$end) { $end = $end-(5-$num); } print "<b><i>Showing stories $start to $end</i></b>"; for ($count=0; $count<$num; $count++) { print "<hr>"; $story = mysql_fetch_array($stories,$count); $id = $story['id']; $headline = $story['headline']; $author = $story['author']; $desc = $story['description']; $content = $story['content']; print "COUNT: $count OF $num ($id)<br>"; print "<a href='index.php?request=story&mstart=$start&story=$id' class='headlinelink'>$headline</a><br>"; print "<div class='author'>Posted by: <a href='index.php?request=author&mstart=$start&author=$author' class='author'>$author</a>.</div>"; print "<div class='desc'>$desc</div><br>"; } } else { print "Error. No stories found. :("; } ?> Output: (The COUNT x OF y was to help me figure out what is wrong. In the () by it is the id number of the corresponding MySQL row/column. I even deleted one of the articles to see if it was a specific article error. No luck.) Quote Newest Stories Showing stories 1 to 5 ---------------- COUNT: 0 OF 5 (6) Y U NO STAY Posted by: craigory83. GRRR ---------------- COUNT: 1 OF 5 (5) h-l! Posted by: craigory83. desc ---------------- Notice: Undefined index: id in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\dba\menu.php on line 37 Notice: Undefined index: headline in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\dba\menu.php on line 38 Notice: Undefined index: author in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\dba\menu.php on line 39 Notice: Undefined index: description in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\dba\menu.php on line 40 Notice: Undefined index: content in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\dba\menu.php on line 41 COUNT: 2 OF 5 () Posted by: . ---------------- COUNT: 3 OF 5 (2) This is the second story! Posted by: TDWP83. See, I fuckin told you so! Warning: mysql_fetch_array() [function.mysql-fetch-array]: The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\dba\menu.php on line 36 ---------------- COUNT: 4 OF 5 (1) This is the mother fucking headline! Posted by: craigory83. stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff I have a development machine running WAMP on a win7 64 bit box. php 5.3.13
I have a server that runs Apache 2.2, php 5.3.12 MySql, etc.
I am running joomla 2.5.27 on both machines.
I require a number of php includes to many of the joomla articles (this works great via a plugin called Directphp)
After considerable time getting the site fully working on the dev machine, I ran into an unforseen problem when I uploaded to the production box.
For some unknown reason, the includes work fine on the dev machine using $DOCUMENT_ROOT to define the root (then tag the correct path and file to this)
However, on the production box, this doesn't work - but... $_SERVER['DOCUMENT_ROOT'] does.
Annoyingly, $_SERVER['DOCUMENT_ROOT'] won't work on the dev machine - and $DOCUMENT_ROOT doesn't work on the production box.
So, I can't come up with a generic method to keep both machines happy.
I've checked the php.ini files on both boxes and the register global is OFF on both.
They also seem to interperate the syntax differently in the actual include files - one box hates double quotes - the other has issues with single quotes.
This is really annoying as most of the includes are HTML snippets, coded into php.
The double/single quote problem means I would need to have two versions of the include files.
Can anyone help me with this? - serious hair pulling has started!
How can you prevent your browser from caching a page? I think that my news feed is being cached and is causing new posts to not be displayed even after a refresh. Eventually, the posts will show up after about 20 refreshes. I know my query is right so I didn't know if there was a way to stop page caching. I don't really know if it is a caching issue though. I'm starting to think I just have some weird bug in my code because sometimes on refresh news feed items get removed then i'll refresh again and some will get added back in then i'll refresh again and they'll all be there. Ever heard of this happening? tore the forum apart looking for a solution to this one. for some reason, this is generating an 'unexpected $end' error. this is ALL the code. in entirety. i was just messing around getting familiar with filesystem stuff. no short tags. no curly brackets. so... Code: [Select] <?php $fileHandler = fopen("someFile.txt", 'w') or die ("could not create file"); $text = <<<_END drop some text and some stuff plus this stuff some other stuff _END; fwrite($fileHandler, $text) or die ("could not write to file"); fclose($fileHandler); echo "File 'someFile.txt' written successfully"; ?> thanks people. this has be stumped. not like its complicated, eh? and as you can see, screws up the colour coding as well... but WHY!?!? WR! has just solved it, can be deleted. I have an array from the database like so Array (2) ( | ['0'] => Array (4) | ( | | ['f_fid'] = String(1) "1" | | ['0'] = String(1) "1" | | ['f_names'] = String(99) "a:4:{i:0;s:18:"register_user_name";i:1;s:5:"r_u_n";i:2;s:10:"user_alias";i:3;s:12:"nickusername";} " | | ['1'] = String(99) "a:4:{i:0;s:18:"register_user_name";i:1;s:5:"r_u_n";i:2;s:10:"user_alias";i:3;s:12:"nickusername";} " | ) | ['1'] => Array (4) | ( | | ['f_fid'] = String(1) "2" | | ['0'] = String(1) "2" | | ['f_names'] = String(104) "a:4:{i:0;s:18:"register_password";i:1;s:5:"r_pass_word";i:2;s:10:"user_pass";i:3;s:12:"reg-pass-word";} " | | ['1'] = String(104) "a:4:{i:0;s:18:"register_password";i:1;s:5:"r_pass_word";i:2;s:10:"user_pass";i:3;s:12:"reg-pass-word";} " | ) ) So i use a foreach loop to turn the serialized value into an array foreach($fields as $key => $val) { $fields[$key]['f_names'] = unserialize($val['f_names']); } But for some reason the last f_names is false Array (2) ( | ['0'] => Array (4) | ( | | ['f_fid'] = String(1) "1" | | ['0'] = String(1) "1" | | ['f_names'] => Array (4) | | ( | | | ['0'] = String(18) "register_user_name" | | | ['1'] = String(5) "r_u_n" | | | ['2'] = String(10) "user_alias" | | | ['3'] = String(12) "nickusername" | | ) | | ['1'] = String(99) "a:4:{i:0;s:18:"register_user_name";i:1;s:5:"r_u_n";i:2;s:10:"user_alias";i:3;s:12:"nickusername";} " | ) | ['1'] => Array (4) | ( | | ['f_fid'] = String(1) "2" | | ['0'] = String(1) "2" | | ['f_names'] = Boolean(0) FALSE | | ['1'] = String(104) "a:4:{i:0;s:18:"register_password";i:1;s:5:"r_pass_word";i:2;s:10:"user_pass";i:3;s:12:"reg-pass-word";} " | ) ) Anyone have any idea why? Thanks Hey, been banging my head against the wall for a couple of hours now. There is an If () in the code that is driving me crazy because it is not behaving like I expect it to.. foreach ( $types as $type ) { if ( !isset( $type->modclass ) or !isset( $type->typestr ) ) { debugging( 'Incorrect activity type in ' . $modname ); continue; } $var = (string)$type->type; if ( $var != 'assignment&type=online' ) { print '<br/>' . $var . '<br/>'; if ( $type->modclass == MOD_CLASS_RESOURCE ) { $resources[$type->type] = $type->typestr; } else { $activities[$type->type] = $type->typestr; } } } results in... Code: [Select] label resource&type=text resource&type=html resource&type=file resource&type=directory resource&type=ims assignment_group_start assignment&type=upload assignment&type=online assignment&type=uploadsingle assignment&type=offline assignment_group_end Notice the assignment&type=online in the output... I'm just about ready to give up as to why it is still outputting $var when it is clearly equal to the compared string? Any ideas? This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=350068.0 Hi all, I can't find anything about this, but maybe someone knows this. the code below works as it should except when it is being included for some reason the filter function doesn;'t work and i get a pop up... $string = "<script> alert('koekoek')</script>"; echo 'string = '.filter_var($string, FILTER_SANITIZE_SPECIAL_CHARS).'<br />'; -edit: the string is normally is retrieved from a $_POST['var'] like: $query = $_POST['query']; echo 'query: '.filter_var($query, FILTER_SANITIZE_SPECIAL_CHARS).'<br />'; and thats when it seems to not work when included edit2: Now i changed the code a bit and put the filter function before echoing it, and than it works... may i assume that it should not be used in the echo directly? $query = filter_var($_POST['query'], FILTER_SANITIZE_SPECIAL_CHARS); echo $query; Im getting a realy weird error i my page. Quote Parse error: syntax error, unexpected T_VARIABLE in /pathtoroot/subscribers.php on line 1 Code: [Select] <?php session_start(); include 'header.php'; include("connect.php"); $username = $_SESSION['username']; $id = $_SESSION['uid']; How on earth is there an error there lol? So suppose I have a mysql table like the following Col1 Col2 Col3 Row1: A 10 2012-3-21 13:20:09 Row2: A 12 2012-3-20 12:04:09 Row3: A 5 2012-3-20 12:03:03 I need a query which will fetch me Row1 and Row2 given that I am searching for A, if the query sees that two rows occur on the same date, it should return the latest one. Any thoughts? Hi, I was looking around the web for a image resizer script and I came across this one. http://www.scriptol.com/scripts/thumbnail-maker.php The weird thing is, it says to use this syntax to get it to work php resizer.php -j myimage.png Well.. I don't seem to understand how that makes it work, Normally I would run a php script by looking for it's main function and running it like: mainfunction(); Maybe I'm interpreting it wrong, but how is this script suppose to run? I am simple using include to include a file within the webpage. include $file; $file does exist and is a string. This works fine locally but when testing on my live server it isnt included and nothing below the include is executed, not even plain html. The error log shows nothing, and there are no errors on screen even when using E_ALL. So i decided to make $file point to the file on the server to see if it was picking it up and it does. So why doesnt the live server want to include this file? The file consists of php and html but there arent any errors. It wouldnt work locally if there were. Any ideas? I am having this weird session anomaly. When logged is as a regular user, all is well until I get to this one page in particular. Once I click the link to get to this page, I become logged in as someone else. The domain is consistent across, and session_start(); is present on all pages. Is there some check that I can use to figure out why this happens every time? Thanks. I'm inserting some data from a CSV file into a database. I'm using mysql_real_escape_string to escape a string and getting some really weird output. ex. input string = Adobe CS5 output = \0\0A\0d\0o\0b\0e\0 \0C\0S\05 I plugged the string into mb_detect_encoding and it told me it was in ASCII and I did a bunch of searching to find out that \0 is a null byte. The only thing I can't figure out is how to convert it to something that won't give me that garbage when I run it through mysql_real_escape_string. I tried mb_convert_encoding($str,"ISO-8859-1","ASCII") and it didn't do anything. Anyone know something I can try?? Hey guys! Well this is actually kind of a weird problem I have been having, and not too sure why I'm getting this problem. I've tried a lot of stuff, and it doesnt seem like I've been able to find a solution. I've been trying for about a month. Anyways, I have a website created with some OOP. Well, once I write an include statement to include a file, which then includes all my classes, it messes up my font, moves my website content down, and well.. it just does weird stuff. However, once I comment the include out, the website looks normal again. so basically, I can comment out the file itself and everything is just fine. But it only happens when I include my class files. Any ideas or suggestions would be amazing! Thank you! So, I wrote a little function the other day to fetch an array of elements out of character-separated-data (like "value1|value2|value3", but then fetched into an array using explode()). The only thing is just that it isn't working at all[/]. Every time I run the function, and catch it as an variable to use it as an array, it simply outputs the word "media", with each character separated into one array-element. Could anybody figure out what's wrong with my code? (Aside from my style, I know it's horrible. I'm halfway learning OOP) Any help would be greatly appreciated. Code: [Select] if(!function_exists('getText')) { function getText($item) { $text = explode(" | ", $data["text"][$item]); $text = Array(0=>"")+$text; return Array(1=>$data["text"][$item]); //outputs Array(0=>"", "m", "e", "d", "i", "a") } } |