-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
[SOLVED] Invalid argument supplied for foreach()
mikesta707 replied to sawade's topic in PHP Coding Help
Well that error happens when you put a non array into the foreach statement. make sure that you are indeed supplying an array into the foreach. Perhaps try doing a print_r before you execute the foreach and see if you are indeed passing an array into the foreach (which it would appear you are not) -
hmm, well I see a different problem that is perhaps unrelated. Your if statement if (isset($_POST['model'])) doesn't do anything. There are no opening or closing brackets, so it just executes the line below, which is empty. Im assuming the 4 lines below that statement are meant to be in the if's code block, so try surrounding that stuff with brackets if (isset($_POST['model'])){ $model = $_POST['model']; echo $makech; ?><br><? echo $model; ?><br /><? session_destroy();//don't know why this is here so this may or may not belong inside the code block } beyond that, assuming your form is posing correctly, and you have the form names right (which it appears you do) I can't really spot a different problem
-
your $model variable never seems to be set in the following code block if (isset($_POST['model'])) $making = $_GET['rowModel']; echo "$makech"; ?><br><? echo "$model; session_destroy(); try setting it $model = $_POST['model']; echo $model
-
[SOLVED] Help displaying information from a database.
mikesta707 replied to The.Pr0fess0r's topic in PHP Coding Help
not sure if this is the cause of your problem , or a simple copy paste error, but there is a syntax error in the 2nd or 3rd line in your code <?php //Database host / ssername /password $conn = mysql_connect("localhost", "myusername", "mypassword); should be <?php //Database host / ssername /password $conn = mysql_connect("localhost", "myusername", "mypassword");//<-missing a quotation mark -
thats because your get variable "splash" isn't a boolean value, its a string. the if statement will only run false if the get variable has a null value. try something like if ($_GET['Splash'] == "true") { // insert code to load the splash page echo "you are not on the splash page!"; } else { // insert code to load normal index.php echo "Welcome to the splash page!"; } ?>
-
if (isset($_SESSION['MyLoginSession']) && !empty($_SESSION['MyLoginSession'])){ # } else { echo "logout to see this page"; } ?
-
$extra_alb_qry .= " AND `cat_id` = " . $_GET['genre']; $extra_alb_qry .= " ORDER BY `id` DESC"; ? I don't get what your problem is so im with dan. cool story bro, i guess...
-
Ok, so you want it to only go to the members section after login if they get redirected from the /members/ section page link? well one solution would be to have the redirect on that page also page a GET variable, and on the login page have it redirect to the members section of that get variable is set (or equal to a certain value).
-
I don't really understand what you are trying to do, but let me see if i got this straight. You have 1 login.php page? Currently, regardless of what links you click, if you login from this page, you are taken to the myaccount section. What you want to do is make it go to the members section instead of myaccount section? well thats very simple... just change the link/header/redirect from myaccount/whatever.html to members/whatever.html did i understand you correctly
-
Yeah its very possible. You need to create a database for the questions that get submit, and on that database, have a column with the amount of times that specific question has been submit. Whenever someone chooses that question, update its counter. To create the dropdown, just select everything from the answers table, and iterate through the results, while echoing out the HTML to create the drop down menu in pseudocode while(row = mysql fetch array){ echo "<option>".row['question']."</option>"; }
-
yeah I failed at regex but you can use str replace, and just replace the begin and end with nothing IE: $toreplace = array('eval(base64_decode("', '"));'); $file = str_replace($toreplace, "", $file);
-
ahhh OK, if it starts and ends the same you can use regex very easily to do what you want. I'm very bad at regex but let me try to whip up a function for you. its coming hold on
-
well how exactly are you testing it. It seems that you just check if the feedback response has the word "test" in it, and if so it sends to a specific email address. Oh on a completely unrelated note. the following code: if (!ereg('^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$', $email)) { print "that is not a valid email address. Please return to the previous page and try again."; #insert a die() or an exit() command here if you want to terminate the script } doesn't do anything but print its not a valid email address. if you want to stop it, use an exit() or something. back on topic, what email address should it be send to? try writing if (mail($toaddress, $subject, $mailcontent, $fromaddress)){ echo "Success!"; } else { echo "Epic Fail"; } instead of just mail($toaddress, $subject, $mailcontent, $fromaddress); and see what happens
-
well first off, I don't see anywhere where you post the variable, or put the variables in a get variable. The only get variable you pass is the job ID on your editjobs.php page. try making the link into a button, and have the button submit a form that all the text areas are a part of.
-
one thing I spotted if(eregi('test', $feedback)) $toaddress = 'd_veraz@hotmail.com'; else if(eregi('test', $feedback)) $toaddress = 'rockindano@hotmail.com'; this block tests the same thing twice, but has two different outcomes. Perhaps its sending an email to an address you don't expect it to because of this. Also, I think eregi() is deprecated
-
Need to limit the character count to 140 in a text area
mikesta707 replied to tecate1's topic in PHP Coding Help
after this if($_POST['submit']){ if(!isset($_SESSION['user']['username'])) $username = "Anonymous"; else $username = $_SESSION['user']['username']; put what daniel0 said. so something like if($_POST['submit']){ if(!isset($_SESSION['user']['username'])) $username = "Anonymous"; else $username = $_SESSION['user']['username']; if (strlen($_POST['comp']) > 140) { echo 'too long'; exit(); } @$query = mysql_query("INSERT INTO `comps`(time,message,accepted,votes1,votes2,via,user,cat,numcoms,subcat) VALUES ('". time() ."', '". clean($_POST['comp']) ."', 'No', 0, 0, 'internet', '". $username ."', '". clean($_POST['cat']) ."', '0', '0')") or die(mysql_error()); by the way that code is a mess -
are you absolutely sure that the age columns is named 'age'? could it be Age? AGE? AGe? AgE? aGe? etc.
-
does the random string fit a pattern? if so you can use a regular expression. if its truely random, than im not sure how you would go about replacing it 100% effectively every time
-
there is no need to echo HTML, you can just put raw HTML between your php code blocks, and everything will stay the same. In fact, I would suggest instead of echoing the HTML and BODY tag, you put them up top. What I suspect is happening is that your if statement is running false, and the HTML and body tag are not being output, so the page is not valid HTML. try <html> <body> <?php if(isset($_SESSION['usname'])) { $data = mysql_query("SELECT * FROM Users WHERE username = '" .$_SESSION['usname'] . "'"); $info = mysql_fetch_assoc($data) or die(mysql_error()); echo "Login Successful<br /><br />"; echo "Your age is: " . $info['age'] . "<br /><br />"; echo "<a href='logout.php'>Logout</a>"; } ?> </body> </html> That should fix your HTML 500 error. By the way this script assumes that the your table has a username field that stores the usernames and an age field that stores the age.
-
Need to limit the character count to 140 in a text area
mikesta707 replied to tecate1's topic in PHP Coding Help
you could also set the max length via javascript, but you may also want to use PHP as javascript can be disabled client side. However, the javascript option may make it a little less tedious for a user, so they don't accidently tyoe say 141 characters, and have to go back to the previous page again. But its all personal preference really. You could also use javascript to dynamically show the amount of characters left that they can type -
recursion is awesome don't be a hater =P But how exactly does your script work? I've never used a web spider before so I would probably have to see the inner code to give any advice. depending on how the loop works, it might might just prevent an infinite loop by itself. You could set a cap for how many times it can loop (IE if i > say 5000, break;)
-
ahh ok, well you could create a function to strip the string of whatever you want to disregard, and do a simple equal comparison function isEqual($string, $string2, $disregard){ $string = str_replace($disregard, "", $string); $string2 = str_replace($disregard, "", $string2); if ($string == $string2){ return true; } else { return false; } } $disregard = array(":", ";", "'", ",", "."); $answer = isEqual("Hello, my name's johnny;;", "Hello. my names johnny", $disregard); echo $answer; ?> Output: 1
-
Ok i fixed it. If anyone is curious, I used the array splice method. Here is the full function: public function getNumericCols(){ if ($this->data == null || !is_array($this->data)){ print_r($this->data); $this->error($this->errors['INVALID_DATA_TYPE']); } $temp_cols = array(); $non_cols = array(); $arr = $this->data; foreach($arr as $row){ $row = array_values($row);//my array is associative, so I need to make it numeric, because I want col nums, not name foreach($row as $key => $cols){ if (ctype_digit($cols) && !in_array($key, $non_cols)){ if (!in_array($key, $temp_cols)){ $temp_cols[] = $key; } } else { if (!in_array($key, $non_cols)){ $non_cols[] = $key; } if (in_array($key, $temp_cols)){ $key1 = array_keys($temp_cols, $key); array_splice($temp_cols, $key1, 1); } } } } print_r(array_slice($this->data, -5, 5)); echo "<br />"; print_r($temp_cols); } The output was first print_r: Array ( [0] => Array ( [ORG_ID] => txsabor [TABLE_NAME] => LST_CH_RESIDENTIAL [FIELD_NAME] => ORG_ID [COUNT_ALL] => 13185 [COUNT_POPULATED] => 13185 ) [1] => Array ( [ORG_ID] => txsabor [TABLE_NAME] => LST_CH_RESIDENTIAL [FIELD_NAME] => LISTING_ID [COUNT_ALL] => 13185 [COUNT_POPULATED] => 13185 ) [2] => Array ( [ORG_ID] => txsabor [TABLE_NAME] => LST_CH_RESIDENTIAL [FIELD_NAME] => AD_GEO_ZIP_CODE [COUNT_ALL] => 13185 [COUNT_POPULATED] => 12425 ) [3] => Array ( [ORG_ID] => txsabor [TABLE_NAME] => LST_CH_RESIDENTIAL [FIELD_NAME] => IN_LIST_DATE [COUNT_ALL] => 13185 [COUNT_POPULATED] => 12827 ) [4] => Array ( [ORG_ID] => txsabor [TABLE_NAME] => LST_CH_RESIDENTIAL [FIELD_NAME] => IN_LIST_PRICE [COUNT_ALL] => 13185 [COUNT_POPULATED] => 13185 ) ) Second print_r: Array ( [0] => 3 [1] => 4 ) As you can see the last two columns (index 3 and 4) are numeric. the others are not, so this worked well.
-
What do you mean by "compare" are you trying to check if they are equal? check if they match a certain regular expression pattern? check if a string is inside another string?