Philip
Staff Alumni-
Posts
4,665 -
Joined
-
Last visited
-
Days Won
20
Everything posted by Philip
-
'$logged[username]' = 'username' should be `username` = '$logged[username]' column names are always surrounded by backticks (`) and values by single quotes (')
-
[SOLVED] Counting How Many Lines Are Inside Certain Markup Tags.
Philip replied to Vermillion's topic in PHP Coding Help
It's because it returns an array item for each instance of the blocks. So $result = countLines($string); if(isset($result[0]) echo $result[0]; // the above line will show how many lines in the first [code] block if(isset($result[1]) echo $result[1]; // this one shows the second, if it exists... etc.[/code] -
Getting Parse error: syntax error, unexpected '<' in
Philip replied to Iank1968's topic in PHP Coding Help
Post your full code, not just // some php Something in that some php it whats causing your error most likely. -
[SOLVED] concatenate text and variables in php
Philip replied to kevinritt's topic in PHP Coding Help
A few ways: echo 'Hello, ' .$_SESSION['username']. 'it is ' .date('F j, Y'). 'and the time is ' .date('H:i:s'); echo 'Hello, ',$_SESSION['username'],'it is ',date('F j, Y'),'and the time is ',date('H:i:s'); echo "Hello, {$_SESSION['username']} it is ".date('F j, Y')."and the time is ".date('H:i:s'); -
You need to make sure to escape the quotes, <?php $EmailFrom = "matthewdipalma@gmail.com"; $EmailTo = "matthew0dipalma@gmail.com"; $Subject = "FORM"; $Name = Trim(stripslashes($_POST['Name'])); $Filename = Trim(stripslashes($_POST['Filename'])); $OtherInformation = Trim(stripslashes($_POST['OtherInformation'])); $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } $Body .= "Name: "; $Body .= $Name; $Body .= "n"; $Body .= "Filename: "; $Body .= $Filename; $Body .= "n"; $Body .= "OtherInformation: "; $Body .= $OtherInformation; $Body .= "n"; $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> You could also do: <?php $EmailFrom = "matthewdipalma@gmail.com"; $EmailTo = "matthew0dipalma@gmail.com"; $Subject = "FORM"; $Name = Trim(stripslashes($_POST['Name'])); $Filename = Trim(stripslashes($_POST['Filename'])); $OtherInformation = Trim(stripslashes($_POST['OtherInformation'])); $validationOK=true; if (!$validationOK) { print '<meta http-equiv="refresh" content="0;URL=error.htm">'; exit; } $Body .= "Name: "; $Body .= $Name; $Body .= "n"; $Body .= "Filename: "; $Body .= $Filename; $Body .= "n"; $Body .= "OtherInformation: "; $Body .= $OtherInformation; $Body .= "n"; $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); if ($success){ print '<meta http-equiv="refresh" content="0;URL=ok.htm">'; } else{ print '<meta http-equiv="refresh" content="0;URL=error.htm">'; } ?>
-
[SOLVED] IMPORTANT --- ERROR MESSAGE MAKING ME FEEL STUPID
Philip replied to kaimason1's topic in PHP Coding Help
The column 'Book' does not exist in your table, TEST1_contacts, on this line: $query="SELECT * FROM TEST1_contacts WHERE 'Book' LIKE '%$search%'"; -
include('usernamepassworddatabase.php'); You need quotes - and make sure that is the correct path to the file
-
I have to agree with CV on this one. Honestly, I've learned more here by helping than by asking questions. Maybe it's just me, but when someone asks a question and I don't know the answer I'll either go and try to solve it, or see what the reply is and try it myself. If you're going with a certification - w3schools is known, but for beginner stuff, not for the advanced like zend. (IMO) When don't you toot your horn
-
$result = mysql_query($query) or die(mysql_error()); // run query $array = array(); // setup array while($row = mysql_fetch_assoc($result)) { $array[] = $row['col1'].' '.$row['col2']; // set whatever variables you are calling, you can also output here while you are at it } $storeInFile = implode('"\n", $array); // implode array to a single string fwrite($fp,$storeInFile); // write to file Something like that? edit: missing a variable, oops
-
I'm voting on the second one, with the guy facing you. As said, it's more personal as if he's inviting you in to watch the video. I think the flag should be a bit brighter though, but not overwhelming.
-
[SOLVED] Setting array to one variable to display later
Philip replied to ratgurrl's topic in PHP Coding Help
Or just implode() <?php if(is_array($_POST['propExterior'])) $propExterior = implode(', ',$_POST['propExterior']); else $propExterior = $_POST['propExterior']; echo $propExterior ?> -
You need to either pass $var as a parameter, or call it as global: $var = new foo(); function random($var){ echo $var->myFunc(); } random($var); or $var = new foo(); function random(){ global $var; echo $var->myFunc(); } random();
-
[SOLVED] query boggs down my server and I cannot figure out why
Philip replied to jakebur01's topic in PHP Coding Help
It doesnt know which table to update. -
Correct, but when you call: $result = mysql_fetch_array($result); It'll return 1 row result, not a multi-dimension array of the results.
-
[SOLVED] TWO WEEKS AND STILL NO ANSWER ON THIS ONE!!
Philip replied to medaswho's topic in PHP Coding Help
So, the queries are exactly the same? -
[SOLVED] TWO WEEKS AND STILL NO ANSWER ON THIS ONE!!
Philip replied to medaswho's topic in PHP Coding Help
I'm aware that you have data in there, but I'm more concerned about the query itself. When you are getting different results, are your queries the exact same every time? edit: sorry, I just realized that I put print_r in there. it's just habit to put in print_r when debugging mysql queries/results -
Are you sure the name of the column is "name" and not "Name" or something else? while($row=mysql_fetch_array($result)) { if ($id == $end) { break; } $id++; echo '<pre>'; print_r($row); echo '</pre>'; /*$id = $row["id"]; $email = $row["email"]; $name = $row["name"]; echo "<tr class=TableFields><td>$email<td>$name</td>"; echo "<td class=LinkText align=center><a href=newsmailerlist.php?action=2&email=$email>Edit</a></td>"; echo "<td class=LinkText align=center><a href=newsmailerlist.php?action=3&email=$email>Delete</a></td>";*/ } The code above will show you what the proper array keys are.
-
Change: $result = mysql_query($q, $con); to $result = mysql_query($q, $con) or die(mysql_error()); You should put the or die on the query, not the fetch. BTW - I believe your loop logic is incorrect. Fetch array will return 1 row at a time, what you're doing is calling the array keys -- which turns out to be different column for one row.
-
[SOLVED] TWO WEEKS AND STILL NO ANSWER ON THIS ONE!!
Philip replied to medaswho's topic in PHP Coding Help
Adding to this, are you sure the query is the exact same every time? $q = "SELECT * FROM members WHERE screenname = '$sname' "; echo $q; $result = mysql_query($q) or die(mysql_error()); $row1 = mysql_fetch_row( $result ); // the following will output the data returned from the fetch_row - showing the key names, etc echo '<pre>'; print_r($row1); echo '</pre>'; -
It's because if ($_GET['content_id']="") should be: if ($_GET['content_id'] == "")
-
echo $_POST['Mortgage']... you might be calling the wrong field name from the form If it doesn't echo anything, then add this above $budg_mortgage = $_POST['Mortgage']; echo '<pre>'; print_r($_POST); echo '</pre>';
-
Just as Mark stated earlier about an array, this site has an example code that is similar to what you are wanting: http://20bits.com/articles/random-weighted-elements-in-php/ However, I think the following would be easiest
-
$query = "UPDATE `$tbl_name` SET `amount` = `$budg_mortgage` WHERE `sub-category` = 'Mortgage'"; should be: $query = "UPDATE `$tbl_name` SET `amount` = '$budg_mortgage' WHERE `sub-category` = 'Mortgage'"; ` are for column names, ' are for values (see change @ $budg_mortgage)
-
That's correct