premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
The error is simple, you do not have an array with an index of 0, and in your code somewhere you are trying to access that. Where I do not know, there are not 87 lines of code posted and you failed to highlight where that would have been, which is why you have not received an answer yet.
-
Because you do not have single quotes around it. u.username = 'u2' is what it should be.
-
mysql_query($query_playlist) or die ("SQL Was (playlist): " . $query_playlist . "<br />Mysql Returned: " . mysql_error());
-
First part, no. $sql="SELECT * FROM User_recipesT ORDER BY Recipe_id DESC LIMIT 1 "; Notice the DESC, which Mark and I added in our post. With a timestamp it would be similar (I cannot remember if the desc is needed for timestamps or not. You will have to test this.) $sql="SELECT * FROM User_recipesT ORDER BY Recipe_date DESC LIMIT 1 "; Just change the order by column.
-
That would do it, add it in or remove it before the if then see what happens.
-
Newbie Help needed - preg_match regex line break issues!
premiso replied to youngnickodemus's topic in PHP Coding Help
<?php $string = '<span class="lprice"> £312.34 </span>'; preg_match("~<span.+?;(.+?)</span>~is", $string, $matches); $price = $matches[1]; echo $price; die(); ?> Should do what you want. As a note if you have multiple spans with a ; inside of them you may want to add the class= part. If you do not then this should be fine, especially if it is the first span, as this will only match the first item on the page that matches that regex. -
$sql = "SELECT * FROM recipes ORDER BY recipe_id DESC" $sql = "SELECT count(userid) as userscnt FROM members";
-
[SOLVED] Newbie - Trying to read from a second table
premiso replied to colinsp's topic in PHP Coding Help
The php.net manual. I posted the links there, they should give examples on which each returns. mysql_fetch_array that will tell you the different types and should show you the different ways a data can be returned. If you do not know what an array is, the manual sort of explains those too, but an array is basically a collection of data to put it in simple/lamans terms. Sort of like a filing cabinet, you have folders with labels and inside folders contain files, you access the files by finding the right name then pulling it out, same type of deal. So basically you wanted to access the columns of the mysql query you ran with Numbered indexes (0, 1, 2,3) ($row[0] etc...). Arrays can also be associative ("id", "col2", "col3") which would accessed by $row['id'] ....etc The fetch_array function for mysql, if no 2nd parameter is used, returns a collection with both numbered and associative indexes. So it essentially doubles the array size/data returned. Specifying either row or assoc will give you 1 set of data with how you want to access it. (In this case you wanted to use mysql_fetch_row). Hope that helps. -
basic php/mysql syntax question on a single line of code
premiso replied to cunoodle2's topic in PHP Coding Help
No...a print_r will give him the array indexes names and values just fine. It will work for him to "figure" out how mysql returns his data so he can use the proper array index value. This is a simple 1-time deal for him to see how it is being returned, it is not meant to be kept in there. EDIT: And your post was asking for something specific, this is just finding out what index is being returned from a query with multiple tables. -
if (strtolower($fList[$i]) == "secure" && $standard == 1) { } I do not know if secure is all lowercase, just incase it is not, invoked the strtolower function for checking, and added the "&&" so it checks if standard is 1, if it is and the folder is secure then it should enter that if.
-
[SOLVED] Select multiple type from single mysql column
premiso replied to sford999's topic in PHP Coding Help
$sql = "SELECT * FROM models WHERE type IN(2, 3) AND auth = '1' ORDER BY id"; Sorry, mis read what you were asking. You want either the IN() operator in MySQL or to use a "OR" operator, as you want type to be Either 2 OR 3. -
Your code is messy so instead of doing it for you, I will explain the logic. if ($currDir == "secure" && $secure == 1) { // skip/continue the script. continue; // not sure this will work, cause I cannot tell if you are looping through each directory/where it starts. } I would practice indenting your code properly as it is just a mess if you do not. It really turns people off from helping you, honestly.
-
// From $header="from: AdMiN <help@weloveweed.co.uk>\r\n"; $header.="header two\r\n"; // extra headers $header.="header three\r\n"; // extra headers Just like that.
-
[SOLVED] Select multiple type from single mysql column
premiso replied to sford999's topic in PHP Coding Help
<?php // mysql connection information here. $sql = "SELECT * FROM models WHERE type = '2' AND visible = '1' ORDER BY id"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { echo $row['type'] . "<br />"; } ?> mysql I would suggest reading up on PHP's mysql functions. -
Do you need to handle it? $AuthCode = makeSQLSafe($AuthCode); //database query $query = "UPDATE Users SET EmailConfirmed='1' WHERE AuthCode='$AuthCode'"; $result = mysql_query($query); $rows = mysql_affected_rows($result); if ($rows < 1) { echo 'Nothing was changed.'; }else { echo $rows . " row(s) were updated."; } Simple as that. Whether that is an error, I do not know.
-
[SOLVED] You have an error in your SQL syntax
premiso replied to almightyegg's topic in PHP Coding Help
while($r3 = mysql_fetch_array($result3) or die("SQL Was(r3): " . $sql . "<br />Error returned: " . mysql_error())){ That is not valid to do, the only reason that dies is because after it has looped through this will be false, which it should to exit the loop. Given that is the only way you get the error to popup the error is elsewhere and not in this code, check your included files for SQL statements and add on better error reporting to them.. -
Yep, the shit kicker part is, spam servers know this and set it up that way. This only filters out small servers that are legit, at least imo. It would be nice if they had a deal where you could verify the legitimacy of your server to be allowed and have a probationary period before getting on the "A" list, but oh well.
-
[SOLVED] You have an error in your SQL syntax
premiso replied to almightyegg's topic in PHP Coding Help
Post your full code, not just what you think is the problem. It will help as I doubt that sql statement is the culprit. -
Try opening a gmail account and sending it to that. GMail is really laxed on mail rules. My bet is that Hotmail is auto filtering it as spam and never "accepting" the message. This will most likely be the same for Yahoo and AOL. The gist of it is, if they cannot verify the IP the mail was sent from has a valid MX record associated to that IP they do not accept the mail. You can try adding more headers to be more thorough, but 99% of the time that will not help given the prior issue I specified. As how to go about making the IP associated with your site a valid MX address, I do not have a clue. I have been trying to figure that out for sometime for my own mail server Try adding on more thorough headers and maybe even adding "-fhelp@weloveweed.co.uk" to it, see mail (the mail function) for more information on how to go about adding more headers properly etc.
-
First up, your functions returns before any processing would be allowed. Second I would read up on PHP's proper syntax as it is different than PERL by far. fopen fwrite fclose are the functions you most likely want to look into to translate this information to PHP from Perl.
-
mysql_real_escape_string the text coming from forms being inserted into the DB. addslashes is being depreciated and suggested not to be used. Post the spot where you are inserting if the mysql escape string does not solve this, as chances are you are probably using it wrong.
-
$0 just means use the first matched result, in this case $word, in your replacement. This should preserve the word's case as it is basically the raw form/original word as seen in the text. Hope that helps.
-
[SOLVED] You have an error in your SQL syntax
premiso replied to almightyegg's topic in PHP Coding Help
Yep, keep using the same logic I posted above on each of your sql statements until you get the right one. -
[SOLVED] Newbie - Trying to read from a second table
premiso replied to colinsp's topic in PHP Coding Help
@ = error suppressor, I suggest not using it. Instead when you go into a production (live website) environment turn off display_errors in the php.ini addslashes is being depreciated. I suggest using mysql_real_escape_string instead. <?php $village = mysql_real_escape_string($_POST['vil']); $query = "SELECT * FROM records WHERE church_id='$village'"; $result = mysql_query($query); while($row = mysql_fetch_row($result)) { echo $row[2]." ".$row[3]." ".$row[4]."\n "; } ?> A few things, one always encapsulate array variables (not numbers) in single or double quotes. This prevents an "Undefined Constant" Notice error from occurring. Two, mysql has many functions, the array is nice but you have to specify what you want back or else you get both a numbered index and an associative index back. Using either mysql_fetch_row if you want a numbered index or mysql_fetch_assoc if you want an associative index is preferred. If you have any other questions about that code post it here. -
basic php/mysql syntax question on a single line of code
premiso replied to cunoodle2's topic in PHP Coding Help
Run a print_r on the $row and see how it is being returned. Given that it should give you the proper array index name.