
lemmin
Members-
Posts
1,904 -
Joined
-
Last visited
-
Days Won
2
Everything posted by lemmin
-
I don't think I understand. If you want to copy all of the values of an array to another array, you can just assign it: $SQLQuery = $tp; If that isn't what you mean, could you explain more of what you are trying to accomplish?
-
That should work fine. I can't see a reason for it to give that error with what you have posted. Can you post more of the code?
-
I'm not sure if it will work with your setup, but you might be able to just echo the contents of the file instead of including it: <?php //if file is php: echo file_get_contents("file.php"); ?>
-
Your variables are only in the scope of your popUpData() function. Try having that function return all of the information. <?php function popUpData($type,$id){ [...] return $result; } while($row = mysql_fetch_assoc($result)){ [...] ?>
-
Try something like this: <?php echo "<table><tr><th>Username</th><th>Items</th></tr>"; $firstRow = mysql_fetch_array($result); $lastName = $row['Username']; echo "<tr><td>$lastName</td><td>".$firstrow['Items']."</td></tr>"; while ($row = mysql_fetch_array($result)) { if ($row['Username'] == $lastName) echo "<tr><td></td><td>".$row['Items']."</td><tr>"; else { $lastName = $row['Username']; echo "<tr><td>$lastName</td><td>".$row['Items']."</td></tr>"; } } echo "</table>"; ?>
-
$webmaster is not defined. You initialize a $webMaster.
-
If you want $item to change to what $item is in your PHP, why not just use $item from your PHP? If I understand you correctly, you could accomplish what you want by simply overwriting the query response with whatever is in your PHP: $row['reply'] = $item; If that is not what you are trying to do, try explaining what you are logically trying to accomplish.
-
If I have these three tables: Table 1 t1ID [other fields] Table 2 t2ID t1ID [other fields] Table 3 t3ID t1ID [other fields] If I am only paying attention to, let's say, t1ID = 2 (from Table 1), is there a way to get a count of how many entries in Table 2 and Table 3 have a t1ID = 2 and still return 0 in that case? I want to make sure I still get results in the case that one or both have 0 entries that match. The only way I have been able to do this is with subqueries, but it seems really inefficient to do so (especially when I have to do it for multiple tables). Thanks for any help.
-
The first one would have to be like this to show both words: <p>Business Name <input type="text" name="business" size="30" value="<?print $business;?>"> The second one you posted places the variable inside of literal quotes so that the HTML parses it as a whole string.
-
There will post likely be a $_GET variable where the id is held. If you go to one of these category's page's, you should see the id in the url with the name of the variable to the left of it. Something like "catid=1." In this case, the $_GET variable would be $_GET['catid']. Once you have found what that variable is named, you can use it in place of the static number in your query: <?php $query = mysql_query("SELECT META_KEYWORDS FROM t_cats where ID='".$_GET['catid']."';"); while($array=mysql_fetch_row($query)){ echo $array[0]; } ?>
-
I don't see anything obvious that would cause a syntax error in the code that you posted. It is hard to troubleshoot your code without knowing what the problem is though. Can you please copy and paste the error that you are getting?
-
I think mikesta707 might not understand exactly what you mean (or maybe it is me). If I understand you correctly, you want to store a "reference" to a php variable so that, when it changes in php, it changes in the database? Theoretically this idea isn't logical because you will only be changing the variable in php, so when querying the database, you will already have that value in php. By your example, if you just stored "Hi" in the database without the $username variable, then you can just use the value from the database and concatenate it with whatever the $username variable has changed to ($dbvalue . $), it would be the same thing. Can you be more specific as to what you are trying to accomplish? I think you might be going about this the wrong way.
-
That shouldn't cause a syntax error. That will just evaluate to true if the about_me.userID is not null and is above 0. If your query was failing then the while loop wouldn't even get executed. I think your syntax error is in the PHP, not the SQL. Can you post the code above and below the line where it says the syntax error is?
-
You probably want to set up the database something like this: conditions ConditionID Condition responses ConditionID Response This way you can have multiple responses for one condition. For strings that you want to match exactly, your PHP could be as simple as this: <?php mysql_query("SELECT r.Response FROM responses r, conditions c WHERE r.ConditionID = c.ConditionID AND c.Condition = '".$_POST['msg']."' ORDER BY RAND() LIMIT 1) or die(mysql_error()); ?> If you want to match strings inside of the 'msg' you can use LIKE instead of =. For more complex patterns, you can use regex to parse the string first, and then do the query based on the results.
-
Yes, I would suggest a MySQL database to do this. I'm not sure what you mean by this. The PHP code should be a lot simpler after setting up the database. Depending on how complex the strings are that you are trying to match, it could as simple as a query like this: "SELECT r.response FROM responses r, terms t WHERE t.msg LIKE '%$term%' AND r.termID = t.termID ORDER BY RAND() LIMIT 1" That query would return a single random response that relates to the term that was found.
-
That seems overly complicated for what you are trying to accomplish. What you should do is set up a database with message terms to look for and responses to those answers. The responses could be set up with a many-to-many relationship to the message terms so that you can simple query the answers with a term ID for a random answer that matches. You might even be able to do the matching and retrieving of the response in one query.
-
It is hard to say what about your buttons is not working. Your ajax function accepts a url of a file to run some kind of server-side actions. You are passing it a string that doesn't look like it is a file so that might not even be doing anything. Also, the new code you posted is passing three arguments to that function and, unless you changed the ajax function, it should only be accepting two. I think you might want to do some research on ajax and add some error handling to the code and go from there.
-
Yes, it is finding "a" inside of the html code that you are adding for each additional keyword. One way around this is to make a string (or character) that is unlikely to occur to mark each area as being ready to highlight: <?php function highlight_words($str, $keywords = '') { $keywords = preg_replace('/\s\s+/', ' ', strip_tags(trim($keywords))); $keywords = explode(' ', $keywords); foreach($keywords as $i => $keyword) $keywords[$i] = "/(".$keyword.")/"; $str = preg_replace($keywords, '{[:[|$1|]:]}', $str); return preg_replace("/{\[:\[\|(.+?)\|\]:\]}/", '<span class="highlight">$1</span>', $str); } echo highlight_words("get a quote", "get a"); ?>
-
I don't see anything obvious in that function. When you load the page, does it say there are error? That could keep the javascript from working.
-
PHP voting script with cookies not casting vote
lemmin replied to paulious's topic in PHP Coding Help
Well, when you see an error like that it means that you are trying to send header information after already sending content. I'm guessing that the output from user_reviews.html is being send before a header() call in your PHP. -
PHP voting script with cookies not casting vote
lemmin replied to paulious's topic in PHP Coding Help
That error is from a different page. I am guessing that you have a page that is including user_reviews.html? -
I agree with cags: This would definitely be easier with a database. I think something like this would work for what you are trying to do, though: <?php $f = fopen("users.txt", "r"); $users = array(); while (!feof($f)) $users[] = explode(":", fgets($f)); fclose($f); $f = fopen("class.txt", "r"); $class = array(); while (!feof($f)) $class[] = explode(":", fgets($f)); fclose($f); $addUsers = array(); foreach ($class as $c) { $found = false; foreach ($users as $u) { if ($u[0] == $c[0]) { $found = true; break; } } if (!$found) $addUsers[] = $c; } ?> Then, $addUsers would contain all the information for that user so you could print it.
-
It seems like you don't have any relationship set up between the pictures and their products. I would suggest adding a column to your table for image location. That way, you don't have to iterate through the directory either.
-
PHP voting script with cookies not casting vote
lemmin replied to paulious's topic in PHP Coding Help
Where is $mode set? Try adding this to the top: if (isset($_GET['mode'])) $mode = $_GET['mode']; -
I think rajivgonsalves took your request too literally. If you only want one character, then only print one of them: echo "<a href='characters.php?id=" . $row['character0'] . "'>".$row['character0']."</a><br />"; You have to do that for each line the way you are echoing them. You could do all of that output in a loop if you wanted.