-
Posts
1,437 -
Joined
-
Last visited
Never
Posts posted by papaface
-
-
Papaface......what? That would do nothing at all....read the query and see if it makes sense.
Anyway, you could just execute the select and then use like usort() with a custom function that checks the qscore() and orders the result array. >_>
My example wouldn't. But it was simply illustrating the theory! It IS possible. Technically if you had a field name called "HELLO!" it would work....
-
You can do it like this:
<?php function qscore($str) { return "HELLO!"; } $select = "SELECT * FROM `webpages` ORDER BY ".qscore(`id`)." DESC"; echo $select; ?>
-
The error was he had an extra "
Edit:
Ok maybe he didnt, just my eyes hurting lol. Ignore my code.
-
use
function get_subject_by_id($subject_id) { global $connection; $query = "SELECT * "; $query .= "FROM subjects "; $query .= "WHERE id=" . $subject_id; $query .= " LIMIT 1"; $result_set = mysql_query($query, $connection); confirm_query($result_set); if($subject = mysql_fetch_array($result_set)) { return $subject; } else { return NULL; } }
-
Did you actually read the function info?
<?php $levels = array('83', '174', '276', '388', '512', '650', '801', '969', '1154', '1358', '1584', '1833', '2107', '2411', '2746', '3115', '3523', '3973', '4470', '5018', '5624', '6291', '7028', '7842', '8740', '9730', '10824', '12031', '13363', '14833', '16456', '18247', '20224', '22406', '24815', '27473', '30408', '33648', '37224', '41171', '45529', '50339', '55649', '61512', '67983', '75127', '83014', '91721', '101333', '111945', '123660', '136594', '150872', '166636', '184040', '203254', '224466', '247886', '273742', '302288', '333804', '368599', '407015', '449428', '496254', '547953', '605032', '668051', '737627', '814445', '899257', '992895', '1096278', '1210421', '1336443', '1475581', '1629200', '1798808', '1986068', '2192818', '2421087', '2673114', '2951373', '3258594', '3597792', '3972294', '4385776', '4842295', '5346332', '5902831', '6517253', '7195629', '7944614', '8771558', '9684577', '10692629', '11805606', '13034431'); echo array_search("174",$levels); // returns 1, therefore in element 2 of the $levels array ?>
-
-
There are many ways this can be done. No specific way is correct. Many variations just depends on what you want to use it for.
-
Shouldn't it be:
<?php include 'opendb.php'; $currIndex = $_GET['index']; $query = "SELECT * FROM reviews where m_index = $currIndex"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $Pic = "{$row['m_Link']}"; echo "{$row['m_Title']} <p>". "{$row['m_Review']} <br> <img src='{$row['m_Link']}'>"; } mysql_close($con); ?> </body> </html>
?
-
Or something like.
<?PHP $ar = array("test", "php", "freak"); foreach ($ar as $k => $v) { if ($k == "test") unset($ar[$k]) ; } ?>
-
-
Basically you use this to format the text in the way it was originally formatted in terms of new lines.
When data is inserted into a db it is entered with new lines as
\n
. nl2br allows you to replace the
\n
with
<br />
which creates a new line in HTML.
-
Not sure
<?php $Password = "test£test£"; if(strlen($Password) > 10) { $ErrorMsg = $ErrorMsg . "Your Password is too long, please shorten it.<br>"; //need to prepare strings before putting them back in form field because of magic quotes and to handle special characters $Password = PrepareForForm($Password); $ConfirmPassword = PrepareForForm($ConfirmPassword); } else { echo "correct length"; } ?>
shows correct length on my page...
-
You need to d a lot more than reading a website. You need hands on experience, creating dynamic and complex websites from scratch and from memory.
-
Thanks, works great.
-
No. I dont mean like that. I mean how can I get the value of that specific element as a string.
like
<?php function getAttribute($attrib, $tag){ //get attribute from html tag $re = '/'.$attrib.'=["\']?([^"\' ]*)["\' ]/is'; preg_match($re, $tag, $match); if($match){ return urldecode($match[1]); }else { return false; } } $tag = '<param name="src" value="http://someurl.com/hello.php">'; echo getAttribute("value", $tag); ?>
That will get the value of any element in the string, but I want it get the value when the element's name is "src".
-
Hello,
Can anyone help me in getting the value of this html element using PHP?
<param name="src" value="http://someurl.com/hello.php">
Any help would be appreciated!
-
javascript?
-
Try:
if (isset($_POST["change_email"])) { $token = $_POST["token"]; //generate unique id $uid = md5(uniqid(rand(), true)); $sql = mysql_query("UPDATE admin SET `uid` = '$uid' WHERE `password` = '$token'"); if (!$sql) { die('Could not execute query!: ' . mysql_error()); mysql_close($con); } else { mysql_close($con); $email = $_POST["email"]; //compose email parts $subject = "MHS WTP Control Panel"; $header = "You have changed your login email address for the control panel."; $message = "Please confirm this change by clicking the link below:\r\n"; $message .= '<a href="https://mhswtpmanage.c6.ixwebhosting.com/">https://mhswtpmanage.c6.ixwebhosting.com/</a>'; //if $message was "http://www.google.com/" it works, or if it was "bla sldjfalkdjf" it works. //but it doesnt work with that url. I don't think secure connections have anything to do with it ini_set('sendmail_from','webmaster@mhswethepeople.com'); $sentmail = mail($email,$subject,$message,$header); if (!$sentmail) { die('Could not send mail'); } else { //continue on to next page } } }
-
Its in the wrong place. Possibly inside a { when it should be outside. Theres to much code for me to look through.
-
Not bad coding, just a mistake.....if ($variable = "Hello" && strlen($variable) > 1 && $variable != NULL) { do this }
bad coding, it needs to be '=='
<?php $variable = 'Helfwfwqlo'; if ($variable = "Hello") { echo 1; } ?>
that would echo 1
Bad coding is your
<?php if ((!$variable)&&(!$variable)&&($variable > 1)) { do this } ?>
As you have two conditions which are exactly the same.
-
if ($variable = "Hello" && strlen($variable) > 1 && $variable != NULL) { do this }
-
Might be better to do:
{ $sql=mysql_query("SELECT * FROM pmessages WHERE id=".$_GET['MSGID']." AND recipient='$name'"); while($row=mysql_fetch_array($sql)) { $message=$row['message']; $find = array("<br /","[quote]","[/quote]"); $replace = array("\n","<div id='Quote'><div id='QuoteTitle'>Quote</div>","</div>"); $message = str_replace($find,$replace,$message); echo("Showing message: <b>".$row['title']."</b><br />".$message."<br /><br />This message was sent on ".$row['date']." at ".$row['time']);// } else { echo("You ('".$name."') are not supposed to be reading this."); } mysql_query("UPDATE pmessages SET status=0 WHERE id=".$_GET['MSGID']); }
-
str_replace in your code won't do anything because its not storing the output in a variable. See my code above and post the result.can you echo $message before str_replace and post it here
Ok, according to the echo tests I did, (An echo every time something happens) no effect took place. AKA the str_replace did nothing.
-
Try:
{ $sql=mysql_query("SELECT * FROM pmessages WHERE id=".$_GET['MSGID']." AND recipient='$name'"); while($row=mysql_fetch_array($sql)) { $message=$row['message']; $message = str_replace("<br />","\n",$message); $message = str_replace("[quote]","<div id='Quote'><div id='QuoteTitle'>Quote</div>",$message); $message = str_replace("[/quote]","</div>",$message); echo("Showing message: <b>".$row['title']."</b><br />".$message."<br /><br />This message was sent on ".$row['date']." at ".$row['time']);// } else { echo("You ('".$name."') are not supposed to be reading this."); } mysql_query("UPDATE pmessages SET status=0 WHERE id=".$_GET['MSGID']); }
Can I use a function directly in the query?
in PHP Coding Help
Posted
We're talking about two separate things. You are talking about manipulating the mysql results. I am talking about constructing SQL syntax using a query that returns something to build the syntax.