PHP - Problem With Concenating A String For Some Reason.
I normally don't have a problem with concenation, but for some reason I can't get it work in this case.
I have two form variables: firstname_ord and lastname_ord. I have tried concenating them several ways, and get nothing afterwards. attempt 1: $lastname = "firstname_ord" . " " . "lastname_ord"; attempt 2: $firstname = "firstname_ord"; $lastname = "lastname_ord"; $fullname = $firstname . " " . $lastname; attempt 3: $fullname = "firstname_ord"; $fullname = $fullname. " " . "lastname_ord"; attempt 4: $fullname = "firstname_ord"; $fullname .="lastname_ord"; attempt 5: $fullname = (string)"firstname_ord"; $fullname .= " "; $fullname .=(string)"lastname_ord"; Similar TutorialsHey I have a script that builds an array but for some reason there is a loose integer in the variable which is confusing me and i think its the cause of my syntax errors in javascript. But i got no idea where it is coming from =/ Here is the function i use: Code: [Select] <?php function img($id) { $img = array(); $img['tiles'] = $this->db->getAll("SELECT DISTINCT t.id, CONCAT('data/tiles/',filename) AS f FROM `map_tiles` AS mt INNER JOIN `tiles` AS t ON (mt.tile=t.id) WHERE mt.map_id={$this->db->qstr($id)}"); echo print_r($img); die; //exit(json_encode($img)); // turned off for testing ?> The echo returns this: Code: [Select] Array ( [tiles] => Array ( [0] => Array ( [id] => 10 [f] => data/tiles/floor.png ) ) ) 1 <----- why does this appear? And could this cause a syntax error if sent back for JS processing? As you can see there is 1 showing at the end but i don't see why =/ Any ideas if thats suppose to happen ? for the below code, what does the get_magic_quotes_gpc part mean?... in simple terms Code: [Select] $photoname = $_FILES['photo']['name']; if(!get_magic_quotes_gpc()) { $photoname = addslashes($photoname); } Here are the two if statements: if (!($start <= 0)){ $prev_button = "<a href='forum.php?category_id=$category_id&start=$prev'>Prev</a>"; } if (!($start >= $record_num - $per_page)){ $next_button = "<a href='forum.php?category_id=$category_id&start=$next'>Next</a>"; } But they are not properly working. This is part of a pagination script for the next and previous buttons. I have this code below in a while loop, that gets looped through about 10 times and is simply resizing a slightly larger image to fit within a 50px max square. There is other code on my page, but I've narrowed the slowness down to this specific bit of code (i.e. if I take this snippet out, the page loads instantly). With this snippet, the page takes between 5 and 10 seconds to load, which seems absurd for 10 images. FYI, the original images are no larger than 200 px on either side, so it's not like it's looping through large image files. Anyone know why this might be taking so long? Should I be doing it differently somehow? Code: [Select] list($width,$height) = getimagesize($myimage); if ($width > $height) { $datasofar .= "width=50 /></span>"; } elseif ($height > $width) { $datasofar .= "height=50 /></span>"; } else { //height and width must be equal so just set width = 50, but could just as easily set height to 50 $datasofar .= "width=50 /></span>"; } Used to be a good option, but don't know anymore as password_hash() is now available.
Agree?
I understand that I shouldn't ever manually salt and disable the functions salting. That being said, is there any reason to add a bit extra to the user's password (such as an internal ID and some random constant)?
I've noticed some people don't use { } when they right statements, when I first started learning PHP a couple years ago, I thought you HAD to put the curly brackets, but apparently not, how does this work and why don't some people use them in their scripts? I spent the last hour or so typing this code up, and for some reason I am getting a query error. I have reviewed & revised the code up and down for the past half hour and can't seem to figure out the problem. Can someone look after this for me and tell me what I could be doing wrong? Yes, I know my code is a bit sloppy and may use bad practice techniques, but it works for me. Its a survey that I coded so I could collect data and place it on CPA ad listings. So I need this so work at some point soon. My code: <?php $user = $_POST['user']; $email = $_POST['email']; $password = $_POST['pass']; $paypal = $_POST['paypal']; $q1 = $_POST['q1[favsite]']; $q2 = $_POST['q2[isp]']; $q21 = $_POST['q2.1[bill]']; $email_services = $_POST['email_services']; $ebay = $_POST['ebay']; $amazon = $_POST['amazon']; $q6 = $_POST['q6[purchase]']; $q7 = $_POST['q7[social]']; $q8 = $_POST['q8[bookmarks]']; $q9 = $_POST['q9[search]']; $q10 = $_POST['q10[homepage]']; $q11 = $_POST['q11[5topsites]']; $q12 = $_POST['q12[state]']; if ($_POST['fin'] == "complete") { $dbc = mysqli_connect('localhost', 'root', 'password', 'database') or die('Could not connect'); $query = "INSERT INTO user_data (id, user, email, password, paypal, q1[favsite], q2[isp], q21[bill], email_services, ebay, amazon, q6[purchase], q7[social], q8[bookmarks], q9[search], q10[homepage], q11[5topsites], q12[state]) VALUES ('$user', '$email', '$password', '$paypal', '$q1', '$q2', '$q21', '$email_services', '$ebay', '$amazon', '$q6', '$q7', '$q8', '$q9', '$q10', '$q11', '$q12')"; mysqli_query($dbc,$query) or die('Error querying database'); include_once("../phpmailer/class.phpmailer.php"); $mail = new PHPMailer; $mail->ClearAddresses(); $mail->AddAddress('', ''); $mail->From = ''; $mail->FromName = ''; $mail->Subject = 'Thanks for finishing the survey!'; $mail->Body = "Hello, $user. This is a reminder that you have finished the survey and your credit is currently being processed. Please login to your account at ../../ to view the status of your credit & cash out. "; if ($mail->Send()) { echo "<center>Mail Sent.</center>"; } else { echo $mail->ErrorInfo; } echo "<center><h2>Thanks for completing the survey! Please <a href='login.php'>login</a> to your account to view the status of your credit & cash out.</h2></center>"; } ?> It has nothing to do with PHPMailer, I of course edited the variables just now so all my info wouldnt be public, but everything is fine untill you press submit & I get the or die() error message "Error querying database". What the hell did I do wrong? Is it possible that I cant name variables in the format I used with most of them ($var1 = $_POST['var[desc]']; ? Hey guys. I'm having a problem with my code and I can not seem to understand what's wrong.. My suspicion is that the $string gets too big or something.. but I'm not quite sure. $subject = $_GET['sub']; $message = explode("|", $_GET['msg']); $sendto = "email"; $sendfrom = "email"; foreach($message as $user){ $user = explode(":", $user); $activity1 = base64_decode($user[0]); $activity2 = base64_decode($user[1]); $activity0 = base64_decode($user[2]); $string .= "Activity0: " . $activity0 . "<br>" . "Activity1: " . $activity1. "<br>" . "Activity2: " . $activity2 . "<br>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br>"; } if($subject && $activity1 && $activity2 && $activity0){ $header = 'Content-type: text/html; charset=iso-8859-1' . "\r\n" . 'From: ' . $sendfrom . "\r\n"; mail($sendto, $subject, "<html>" . "<center>" . "<br><br><br>" . " - - - " . "Program logged this activity" . " - - - " . "<br>" . $string . "<br>" . "<b> - meh -</br></center></html>", $header); } else { echo "Failed?"; } So the main point is that a program sends the required information to the php script and it proceeds by splitting it up and showing it in an organized way.. and then sends it to an email. This works flawless until some point where the message gets too big(?) and it'll do else { echo "Failed?"; } instead... Do you guys have any idea what's wrong? Thanks in advance. Hello PHPFreaks, i have 2 problems. The first problem is, that what i want help to is on my other computer. And its not possible for me to get to it atm. So i'll do it as good as i remember. My second problem is, i made a website and i want a login on one of the pages. I made a form etc. The username field is called 'usernamebox' and the password field is called 'passwordbox'. So, in the php part I do like this. <?php $username_string = $_POST['usernamebox']; $password_string = $_POST['passwordbox']; rest of code ... ?> Is there any problem doing that, because my SQL server shows me error every place i try to connect it with the strings? Hello Guys can anyone help me with this? Code: [Select] <?php $common_words = array(" the ", " is "); $title = " The dog is chasing the boy "; $title = strtolower($title); $title_array = explode(" ", $title); $title_words = array(); foreach($title_array as $word) { $title_words[] = str_replace($common_words, " ", $title); } $text = " The dog is chasing the boy. This is an irrelevant sentence. The boy runs away from the dog. This is another irrelevant sentence. "; $sentence = strtok($text, ".?!"); $summary = ''; while ($sentence !== false){ foreach($title_words as $word) { if(strstr($sentence, $word)) { $summary .= $sentence . '. '; } } $sentence = strtok(".?!"); } echo $summary; ?> when i execute this code i get a blank page. I think the problem is on this line: $title_words[] = str_replace($common_words, " ", $title); The expected output is: The dog is chasing the boy. The boy runs away from the dog. I am using the code posted here to do something with a third party software
http://www.interwork...trusted-tickets
however its utterly frutrating that something as simple as
$fullUrl = "http://{$server}/trusted/{$ticket}/{$url}";
returns me the following
moOaH6BAKFMGGszd_IQHTvpAhttp://<server>/trusted/1/views/<dashboard>?format=png
instead of
http://<server>/trusted/moOaH6BAKFMGGszd_IQHTvpA/views/<dashboard>?format=png
completely beats me. Any idea why ? Is it something to do with the variable $ticket which has the value of moOaH6BAKFMGGszd_IQHTvpA in this case ?
I need to see if someone can point out something that I have missed or maybe even point me in the right direction on something. I have a PHP script that I have run into a problem on. The basic idea of the script is that it will send out HTML formatted emails to users of my web site. The problem I am running into is storing the HTML content in memory so I can do a str_replace() looking for certain markers in the HTML and replace them with lets say the users name and custom links that pertain to the particular user that the email is going to. Currently the HTML is being stored in a MySQL database, but I have already tried reading it from a flat file. Each time I only get the first 1024 characters returned. The problem seems to be that I am running into a PHP STRING limitation. From the reading that I have done on the subject, the limit should be 1024 characters PER LINE with the variable able to hold somewhere around 8MB worth of data. I can tell you that it does not matter how many \n I put into the HTML I still only get the first 1024 characters. Is there a way I can get the entire HTML file (about 12k characters) in memory so I can work with it and hand it off to the mail function? Thanks, whit3fir3 Hello guys, I have a form where you can select a score between 0 and 10(only integers).
I want to check if the value that I recive, is integer.
Im using this code(exemple):
$integer = intval($_POST["p1"]); if(is_int($integer)){ echo 'INT'; } else { echo 'NO INT'; }My problem is that if it recive letters, the conversion converts it to 0, and it says that it is integer. So with this method I should discard the 0. You guys know a method to avoid that? Thank you guys
this is what i want in the urlÂ
when this link is clickedÂ
but i keep getting this error: appreciate any help i want to change this code : $result = mysql_query("select count(*) from 3gp where category='Bollywood'"); with this $result = mysql_query("select count(*) from 3gp where category='$category'"); but i am getting error message "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/funxy/public_html/salmobile.info/3gp-videos.php on line 151". I am calling the page using http://abc.com/3gp-videos.php?category=Bollywood Please help. Code: [Select] <?php $db="funxy_db"; $conn = mysql_connect("localhost","funxy_saba","myasco001"); @mysql_select_db($db) or die( "Unable to select database, Please contact your administrator"); class Pager { function getPagerData($numHits, $limit, $page) { $numHits = (int) $numHits; $limit = max((int) $limit, 1); $page = (int) $page; $numPages = ceil($numHits / $limit); $page = max($page, 1); $page = min($page, $numPages); $offset = ($page - 1) * $limit; $ret = new stdClass; $ret->offset = $offset; $ret->limit = $limit; $ret->numPages = $numPages; $ret->page = $page; return $ret; } } // get the pager input values $page = $_GET['page']; $limit = 3; $result = mysql_query("select count(*) from 3gp where category='Bollywood'"); $total = mysql_result($result, 0, 0); // work out the pager values $pager = Pager::getPagerData($total, $limit, $page); $offset = $pager->offset; $limit = $pager->limit; $page = $pager->page; // use pager values to fetch data $query = "select * from 3gp where category='Bollywood' order by id DESC limit $offset, $limit"; $result = mysql_query($query); // use $result here to output page content //my addition //grab all the content //Custom Table Stsrt// $cols = 4; //number of coloms $i =1; echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\" id=\"table1\" bordercolor=\"#FFFFFF\" bgcolor=\"#FFFFFF\">" ."<tr>"; while($r=mysql_fetch_array($result)) { //the format is $variable = $r["nameofmysqlcolumn"]; //modify these to match your mysql table columns $id=$r["id"]; $name=$r["name"]; $views=$r["views"]; $url=$r["url"]; $image=$r["image"]; $category=$r["category"]; //display the row $mybox = " <br> <a href='http://salmobile.info/3gp-videos-download.php?id=$id' class=\"classd\"><b><u> $name</u></b></a> <BR> <span class=\"text\"><img src=\"$image\" width=\"60\" height=\"60\"></span> <BR> <span class=\"text2\">Download This 3GP Video</span> <br>"; if (is_int($i / $cols)){ echo "<td width='336' align='center' style=\"border-style: dotted; border-width: 0\">$mybox</td></tr><tr>"; }else{ echo "<td width='336' align='center' style=\"border-style: dotted; border-width: 0\">$mybox</td>"; } if ( $i / $cols == 3) echo "<td colspan='3' align=\"center\"> </td></tr><tr>"; if ( $i / $cols == 8) echo "<td colspan='3' align=\"left\"> </td></tr><tr>"; $i++; //end if }//end while echo "</tr></table>"; //Custom Table End// //ends my addition // output paging system (could also do it before we output the page content) if ($page == 1) // this is the first page - there is no previous page echo "<font color=\"#FFB300\">Previous</font>"; else // not the first page, link to the previous page echo "<a href=\"http://salmobile.info/index-" . ($page - 1) . ".html\" id=\"navigationURL\"><font color=\"#FFB300\">Previous</font></a>"; for ($i = 1; $i <= $pager->numPages; $i++) { echo " <font color=\"#FFFFFF\">|</font> "; if ($i == $pager->page) echo "<font color=\"#FFB300\"> $i</font>"; else echo "<a href=\"http://salmobile.info/index-$i.html\" id=\"navigationURL\"> <font color=\"#FFB300\">$i</font></a>"; } if ($page == $pager->numPages) // this is the last page - there is no next page echo "Next"; else // not the last page, link to the next page echo " <a href=\"http://salmobile.info/index-" . ($page + 1) . ".html\" id=\"navigationURL\"><font color=\"#FFB300\">Next</font></a>"; ?> Hi, I am trying to make some adjustments to uploadify.php which comes with the latest version of uploadify (3.0 beta), so that it works with a session variable that stores the login username and adds it to the path for uploads. Here is uploadify.php as it currently looks: Code: [Select] <?php session_name("MyLogin"); session_start(); $targetFolder = '/songs/' . $_SESSION['name']; // Relative to the root if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder; $targetFile = rtrim($targetPath,'/') .'/'. $_FILES['Filedata']['name']; // Validate the file type $fileTypes = array('m4a','mp3','flac','ogg'); // File extensions $fileParts = pathinfo($_FILES['Filedata']['name']); if (in_array($fileParts['extension'],$fileTypes)) { move_uploaded_file($tempFile,$targetFile); echo '1'; } else { echo 'Invalid file type.'; } } echo $targetFolder; ?> I added Code: [Select] echo $targetFolder; at the bottom so that I could make sure that the string returned was correct, and it is, i.e. '/songs/nick'. For some reason though, uploads are not going to the correct folder, i.e. the username folder, but instead are going to the parent folder 'songs'. The folder for username exists, with correct permissions, and when I manually enter Code: [Select] $targetFolder = '/songs/nick';all works fine. Which strikes me as rather strange. I have limited experience of using php, but wonder how if the correct string is returned by the session variable, the upload works differently than with the manually entered string. Any help would be much appreciated. It's the last issue with a website that was due to go live 2 days ago! Thanks, Nick Hello all, I'm trying to change the end of a javascript call based on the end of the url string. The common part of all the url strings is sobi2Id=, I'm trying to do this with strstr but am having no luck. I'm new to php so my syntax knowledge is terrible! at the moment i've got Code: [Select] <?php $url = $_SERVER['REQUEST_URI']; $tag = strstr ($url, 'sobi2Id='); echo $tag; ?> but this returns an unexpected T_STRING, expecting ',' or ';' Can anyone debug this? I may well be being really silly! Hey there, Thanks for taking the time to read my thread. My issue is that I can't think of a way to edit a XML file using PHP's XML functionality and then assign the edited contents to a string instead of saving the file. Because my issue is that I have to edit the XML file based upon a string brought from a remote location then give it back to that remote location using a string again, to be exact I am doing it via Linux command line utilizing SSH2. This is what I managed to complete on my own. function CheckIVMPConfig($ServerID) { global $Panel; if(is_numeric($ServerID) && $this->IsValidServer($ServerID)) { // We select the game server that the FTP account was created for. $Servers = mysql_query("SELECT * FROM control_servers WHERE server_id = '".mysql_real_escape_string($FTPAccount['ftp_server'])."'"); $Server = mysql_fetch_array($Servers); // Here we select the Box ID that the game server is on. $Boxs = mysql_query("SELECT * FROM control_machines WHERE machine_id = '".$Server['server_machine']."'"); $Box = mysql_fetch_array($Boxs); // Now we select the required package for the box. $Packages = mysql_query("SELECT * FROM control_packages WHERE package_id = '".$Server['server_package']."'"); $Package = mysql_fetch_array($Packages); // Retrive the file. $Config = $CProtocol->exec("cat /home/{$Server['server_id']}/{$Package['package_config']}"); $Parse = SimpleXMLElement($Config); foreach($Parse as $Entry) // loop through our books { if($Entry->port != $Server['server_port']) { // edit the value } else if($Entry->maxplayers > $Server['server_slots']) { // edit the value } } } } |