lipun4u Posted October 22, 2009 Share Posted October 22, 2009 What is the error in the below code ??? <?php if(array_key_exists_r('email|password', $_POST)) { include_once('database.php'); $sql = "SELECT user_id FROM login WHERE user_name = '" . trim($_POST['email']) . "' AND password='" . trim($_POST['password']) . "')"; $result = mysql_query($sql); print_r($result); if (mysql_num_rows($result)>0){ $row = mysql_fetch_row($result); session_start(); $_SESSION['user_id']=$row[0]; $_SESSION['user_name']=trim($_POST['email']); } } ?> Link to comment https://forums.phpfreaks.com/topic/178600-plz-fix-the-error/ Share on other sites More sharing options...
cbolson Posted October 22, 2009 Share Posted October 22, 2009 What errors are you getting? Link to comment https://forums.phpfreaks.com/topic/178600-plz-fix-the-error/#findComment-941943 Share on other sites More sharing options...
Mchl Posted October 22, 2009 Share Posted October 22, 2009 Nothing, unless you didn't define array_key_exists_r() function. Oh... and $result is not an array, so you cannot print_r() it Link to comment https://forums.phpfreaks.com/topic/178600-plz-fix-the-error/#findComment-941944 Share on other sites More sharing options...
mrMarcus Posted October 22, 2009 Share Posted October 22, 2009 edit: my bad .. thought i saw something that wasn't really there; Link to comment https://forums.phpfreaks.com/topic/178600-plz-fix-the-error/#findComment-941947 Share on other sites More sharing options...
lipun4u Posted October 22, 2009 Author Share Posted October 22, 2009 the error is... Parse error: syntax error, unexpected '<' in F:\Program Files\Apache Software Foundation\Apache2.2\htdocs\submit.php on line 44 line 44 is $_SESSION['user_id']=$row[0]; Link to comment https://forums.phpfreaks.com/topic/178600-plz-fix-the-error/#findComment-941948 Share on other sites More sharing options...
lipun4u Posted October 22, 2009 Author Share Posted October 22, 2009 the required function is defined... <?php function array_key_exists_r($keys, $search_r) { $keys_r = split('\|',$keys); foreach($keys_r as $key) if(!array_key_exists($key,$search_r)) return false; return true; } ?> Link to comment https://forums.phpfreaks.com/topic/178600-plz-fix-the-error/#findComment-941952 Share on other sites More sharing options...
Mchl Posted October 22, 2009 Share Posted October 22, 2009 You're sure this is the line? As you can see there's no < in it or near it... Link to comment https://forums.phpfreaks.com/topic/178600-plz-fix-the-error/#findComment-941953 Share on other sites More sharing options...
cbolson Posted October 22, 2009 Share Posted October 22, 2009 A parse error often referrs to a previous line to the one indicated in the php warning (simply because it doesn't *know* there is an error until it gets to that line) I can't see a "<" in the code that you posted so it is probably happening somewhere else on the page or even in database.php Chris Link to comment https://forums.phpfreaks.com/topic/178600-plz-fix-the-error/#findComment-941955 Share on other sites More sharing options...
lipun4u Posted October 22, 2009 Author Share Posted October 22, 2009 That's the problem, I also don't see any '<'. Before this, I am also including 2 include_once(), will this affect the line number ??? Link to comment https://forums.phpfreaks.com/topic/178600-plz-fix-the-error/#findComment-941957 Share on other sites More sharing options...
mrMarcus Posted October 22, 2009 Share Posted October 22, 2009 post your script from 'F:\Program Files\Apache Software Foundation\Apache2.2\htdocs\submit.php' starting at the very first line down to line 44. edit: and yes, every line counts .. start from the very, very top of submit.php Link to comment https://forums.phpfreaks.com/topic/178600-plz-fix-the-error/#findComment-941958 Share on other sites More sharing options...
lipun4u Posted October 22, 2009 Author Share Posted October 22, 2009 Give me some minutes...to make a strip-down-version as it contains some legacy code... Link to comment https://forums.phpfreaks.com/topic/178600-plz-fix-the-error/#findComment-941960 Share on other sites More sharing options...
Mark Baker Posted October 22, 2009 Share Posted October 22, 2009 $sql = "SELECT user_id FROM login WHERE user_name = '" . trim($_POST['email']) . "' AND password='" . trim($_POST['password']) . "')"; Count the opening and closing brackets Link to comment https://forums.phpfreaks.com/topic/178600-plz-fix-the-error/#findComment-941990 Share on other sites More sharing options...
Mchl Posted October 22, 2009 Share Posted October 22, 2009 Good one. It's a MySQL error however, and not responsible for the warning message. Link to comment https://forums.phpfreaks.com/topic/178600-plz-fix-the-error/#findComment-941993 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.