Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Make Function Equal To String In Conditional


I can usually figure something out, but I CANNOT figure this one out: This is a classified word ad script to count the words in a text area ($wrdad) and multiply it by the rate for how many times the ad will run in the newspaper.  I know my code is messy and ameture, don't be too critical, but it works - everythign except one part. We have a 15 word minimum. I have this area commented out as //Problem Area/// in the code below.

In a nutshell, I want function wordcount($wordad) to be equal to 15 if there are fewer than 15 words in the $wordad textarea. It just seems to ignore the wordcount($wordad) == 15; in my conditional. Code:




View Complete Forum Thread with Replies

Related Forum Messages:
String Function In PHP To Make The Searching Of Tags
I not sure if bbcode was the term for this.. how this can be done? for example in this forum, with the open and closing some code here or [/img]link of image here[/img] and on the display it is display with a ceratin CSS/format or something..is this can be done through "eregular expression"? and before saving on the dbase is converted to <img src"" />? am I right? 

is there a string function in PHP to make the searching of tags easy?

View Replies !
Make Text String Read From Right To Left In Imagettftext() Function
I want to write a text string from right to left instead of from left to right with the imagettftext (); function

I read in teh manual that the angle variable controls this, it says that 0 angle means left to right, so I tried 180, 360 but nothing happens What angle do I need to put it to get it to write it right to left. Code:

View Replies !
Mysql "make String Safe" Function
Is there a function in php that you can pass a string headed for a mysql
query and have it make it 'safe'? For example it would escape out the '
found in the string.

View Replies !
More Than 1 Conditional In A Function
This is a great function I use to echo timestamps as "how long ago" timeframe. This function rounds up the time to the smallest hour, so that 2:55 echos "2 hours ago". The only conditional in this function is Code:

if($difference != 1) $periods[$j].= "s";
and what it does is to add an "s" if the second, minute, hour... is not 1 (pluralization).

I need now to add another conditional so that for anytime greater than 5 hours and less than 24 hours it will echo just the word "Today". I tried many possibilities without much success. Code:

View Replies !
Mysql Real Escape String() In Conditional Statements
I created the following bit of code that allows me to pass a MySQL conditional statement to a function.

I am trying to figure out where and how would I go about incorporating the mysql_real_escape_string() function?

Is there a way to call the mysql_real_escape_string() in the function itself? Code:

View Replies !
Function Like A Conditional Statement
how to use the function which works like a conditional statement.

I think it is something like: 3 < 4 : $something ? $something

View Replies !
Equal Variables Are.....not Equal ?
I have a program that takes a value from a column and stores it into a variable. Then takes a value the user entered in a html form and stores it in another variable. Then it should see if they are the same(they are both strings).

The site works, but I kept getting them unequal. And when I was tesing it I knew the valuse were equal. So I echoed them before the comparison and both are "aaaa". But the if statement sais they are different. The code is big so il try to but only the relevant lines. Code:

View Replies !
Make A String Into An Array
I know there's a simple function to do this just can't remember it. Say I have a string with spaces in it like this: jpg jpeg gif png. How do I break this into an array or manipulate each piece separately basically (I need to check each file type with a string of file types).

View Replies !
Make Numberic String
How do I make a numeric string from 2 vars without adding them together? i.e Code:

$var3 = date("m") & date("d");

// should make 0116.

View Replies !
Make Associative Array Out Of String
I have a string that look something like this:

$string = "weight, kg|1200|width, mm|220|prize|20000";

and I would like it to an associative array and print keys and value:

weight, kg: 1200
width, mm: 220
prize: 20000

(The string above is fetched from a database)

Anyone have any bright ideas how to do it?

View Replies !
How Do You Make A String Of Binary Numbers From An Array
I have an array of numbers, and I need to turn it into a single binary
string. How do I do that?

View Replies !
Concatenate String And Variable To Make Up A Constant Name
I know that it is possible to build up a variable name based on a
string and another variable name i.e.

$varnum=5;
${"varnumber_$varnum"} = 'This variable should be called varnumber_5'

but is it possible to do this for a constant? For example I may have
constants set up as Code:

View Replies !
String Search To Make Sure It Does Not Already Exists In The Database.
In MySql database I store the restaurant names like "My Restaurant &amp; Bar"

On the website before people can add a new restaurant they must search for that restaurant to make sure it does not already exists in the database.

The problem is that when people search for "My Restaurant & Bar" the restaurant "My Restaurant &amp; Bar" that already exists is not found.

View Replies !
Parse Part Of String (mid String Function ?)
Can someone tell me how to parse part of a string? I can use the following:

<?php
$text = $_SERVER['PHP_SELF']; //$PHP_SELF //(document.url);
echo $text;
?>

to get this result:

"Your currently at /test.php "

I just want to get "test.php " without the dash. I also need to parse out
parts of other strings. I know how to use Mid(), Left(), and Right() in VB,
but no clue for PHP.

View Replies !
Purpose Of Function EncodeHeader($String,$String)
is the purpose of function EncodeHeader($String,$String), from class.PHPMailer.php (http://phpmailer.sourceforge.net/) specifically since I am suppossed to come up with documentation for a user who does not know anything about source code...

I understand the regular expressions used, but I can't visualize the input vs outcome, and what is the purpose of such encoding. Is it for the server?

View Replies !
Is It Possible To Make Your Own Function For Encryption?
I am sorry for bringing up *yet another* post about encryption, but I was just curious. Is there a way to make your own encryption function? I mean, that would make it more secure than anything, right? Since no one else would have that encryption key or whatever? Is there a way to look at the current encryption functions like MD5 or crypt? I know it's a lot more complicated than a=1 and b=2, but I think it'd be cool if I could come up with my own form of encryption (with the help of a professor, of course)!

View Replies !
Make Ip Block Function
I would make a ip block script for my site. The blocked ip are stored in a
file.
I have made the following script. Why does this not work. The file entries
must be stored in a array and after that i must check all the fields in the
array. Please help...

<?php
$ip = $_SERVER['REMOTE_ADDR'];
$bestand = "ipblock.txt";
$open = fopen($bestand, "r");

$iparray = file ($open);

$n = 0;

while ($n < count($iparray)) {
if ($iparray[$n] == $ip) {
print ("NOT");
else {
print ("YES");
$n++;
}
}

?>

View Replies !
Make A Function That Returns More Than One Value?
Is there any ways to make a function like system(), which returns more
than one value (true or false) and (the array)

View Replies !
Make A Function, Like Mysql_fetch_array
Is it possible to make a function, like mysql_fetch_array, where data can be put into an array inside a loop expression, without having to do all kind of checks and stuff to end the loop when done pulling out the data? Code:

View Replies !
Function Make $b In B() Print In A()?
how do you make $b in b() print in a()?

<?
a();

function a() {
  $a = "This is a<br>";
  print "$a";
  b();
  print "$b";
}

function b() {
  $b = "this is b<br>";
  return $b;
}

?>

View Replies !
Array Function Or String Function To Compare?
Ok Say I have two arrays:

array1('Bill, Gates, Microsoft, Seattle, USA');
array2('Microsoft,Seattle, USA', 'Microsoft, Washington, USA');

I need to match a portion of array 1 which is: Microsoft,Seattle,USA with array2.

Is there a function that can compare this and return true if a portion of array 1 is in array 2? In this case we find 'Microsoft,Seattle,USA' in array 1 and array 2.

View Replies !
Make $_SESSION Variables A Global In A Function?
i'm have a particular function where it creates session variables, yet after using this function i want to immediately use these session variables

now I realize the only way to "use" variables that are made inside of a function is to make the variable a global variable so it can be used outside the function

so i did this:
global $_SESSION['userid'];
global $_SESSION['username'];
global $_SESSION['userlink'];
global $_SESSION['userifnewmsgs'];
global $_SESSION['userrank'];

however there are many instances when !isset($_SESSION) , when the session variables are not already set

i run this function when the sessions are not set and I get this:
Parse error: parse error, unexpected '[', expecting ',' or ';'

what's going on and how can I fix it?

View Replies !
Is There A Function To Search A String Within Another String ?
for e.g, fnding the word "hello" in this string : "hello world"...

View Replies !
Make Thumnails Of A Video - Ffmpeg Function GetFrame()
I have coded a script that makes thumnails of a video. here is my code:

10) $mov = new ffmpeg_movie($videospath);
11) $duration = round($mov->getDuration(),0).'s'
12) $height = $mov->getFrameHeight();
13) $width = $mov->getFrameWidth();
14) $image = imagecreatetruecolor($width,$height);
15) $frame = new ffmpeg_frame($image);
16) print is_object($frame)." obj1 ";
17) $frame = $mov->getFrame(1);
18) print is_object($frame)." obj2 ";
19) $image = $frame->toGDImage();
20) @imagejpeg($image, $videospath.$vid.'.jpg', 100);

This code works fine for some movies and makes the thumbnail image but for
some movies it did not make thumnails and give the following error.

1 obj1 obj2
Fatal error: Call to a member function on a non-object in
/home/iideshow/public_html/inc/makeVideoPics.php on line 19

In try to debug the error I add two extra statements in my code on lines 16
and 18 and u can see in the output before the calling of function
$mov->getFrame(1); on line 17 the frame object exists but on line 18 it is not.

Can any one guid me wht's the problem here.
Remember it works on some videos but on most of the videos it did not.

View Replies !
Mkdir - Copy Function And Fopen To Make A New File
Ive got a script where people can sign up and a folder is created with their username as the name of it.

I also want to copy files to that directory using the same script but everything Ive tried doesnt work. Ive tried using the copy function and also fopen to make a new file but none of them have worked. Code:

View Replies !
Make A Database Query In One Function And Return The Variable.
If I make a database query in one function and return the variable.

E.g.<?php

$q = "SELECT email FROM ".TBL_USERS." WHERE username = '$username'";
$result = mysql_query($q, $this->connection);
$dbarray = mysql_fetch_array($result);
$email = $dbarray['email'];
return $email;
?>
I can then use that variable when calling the function cannot I?

E.g.<?php

if ($database->getEmail($username)){

$mailer->sendJoin($this->username, $email);
return 0;  //New user added succesfully

} ?>
The only problem is, the script isn't sending the $email variable to the $mailer. It sends the username fine, but the $email is blank. I've tried making an echo in the second set of code I showed you and $email is empty.

View Replies !
How Can I Make A Function That Would Test If The Time Entered By The Employee Is Valid?
I have a program that calculates log in and out of an employee...

My question is how can I make a function that would test if the time entered by the employee is valid

example:

1.) IN : 02:00:00 OUT: 03:00:00 Result: VALID
1.) IN : 22:00:00 OUT: 01:00:00 Result: VALID
1.) IN : 23:00:00 OUT: 22:00:00 Result: INVALID
1.) IN : 02:00:00 OUT: 01:00:00 Result: INVALID
1.) IN : 02:00:00 OUT: 00:00:00 Result: INVALID

View Replies !
$a Is Equal To $b.
$a == $b Equal TRUE if $a is equal to $b.
$a === $b Identical TRUE if $a is equal to $b, and they are of the same type. (introduced in PHP 4)
$a != $b Not equal TRUE if $a is not equal to $b.
$a <> $b Not equal TRUE if $a is not equal to $b.
$a !== $b Not identical TRUE if $a is not equal to $b, or they are not of the same type. (introduced in PHP 4)
$a < $b Less than TRUE if $a is strictly less than $b.
$a > $b Greater than TRUE if $a is strictly greater than $b.
$a <= $b Less than or equal to TRUE if $a is less than or equal to $b.
$a >= $b Greater than or equal to TRUE if $a is greater than or equal to $b. well what about say:

if($clearance == "1")
if($clearance == "2")

how do i put it as - 1 OR 2 ??? or even as.... 1 OR 2 OR 3 ??? also as 1 OR 2 OR 3 OR 4 ???

View Replies !
Does Not Equal
table name has a list of many names, table comment is used to store the comments that people have left about of person(name). The comments are linked to the person(name) by name_id.

<?php

$sql = "SELECT * FROM name";
$result = mysql_query($sql, $conn) or die(mysql_error());
while ($newArray = mysql_fetch_array($result)) {

$name_id = $newArray['name_id'];
$name_name = $newArray['name_name'];

}

$sql = "SELECT * FROM comment WHERE name_id != '$name_id'";
$result = mysql_query($sql, $conn) or die(mysql_error());
while ($newArray = mysql_fetch_array($result)) {.....

View Replies !
Be Equal To 23 And 26
PHP Code:

index.php?Team_ID=23

but i want it to be equal to 23 and 26 so how would it work. PHP Code:


index.php?Team_ID=23 ??? 26

View Replies !
Two Equal Strings?
I was just checking php.net but couldn't find a function that will compare to strings.

Did I just overlook it? or do I have to write a function to compare the two stirngs in php?

If there is a function, which one is it?
If there isn't a function, could you give me an idea of the coding that would compare two strings?


View Replies !
When To Use 2 Equal Signs And When To Use 3
When I had these two lines in my code:

if ($executed == "The command didn't exist") {
$this->core->error("In CommandRenderAllActionsInAnArray we sought
the command '$commandName' but ExteriorCommands could not find it. It
returned the value: '$executed'.", "CommandRenderAllActionsInAnArray");

I was getting this on screen:

# CommandRenderAllActionsInAnArray threw this error: In
CommandRenderAllActionsInAnArray we sought the command
'checkToSeeIfThisIsTheFirstLogin' but ExteriorCommands could not find
it. It returned the value: &#391;'.

But if I change the first line to this:

if ($executed === "The command didn't exist") {

then it works correctly.

Why does this need 3 equal signs? Why doesn't 2 suffice? I've done
string comparisons before and I've never had to use 3 equal signs
before.

View Replies !
Strcmp Vs Equal
I noticed in some examples to the encrypt functions of the PHP manual a
syntax was used for password checks such as

if (strcmp($userpassword, md5($_POST['password'])) == 0) {
// do login
}

What is the advantage of this compared to

if ($userpassword == md5($_POST['password'])) {
// do login
}

?

View Replies !
Set A Variable Equal To Another
Not sure how to set a variable equal to another. $myvar = $myothervar ? Is that right?

View Replies !
Are 2 Equal Signs Ok?
This script says this (it's a login script)...

$this->username = $_SESSION['username'] = $this->userinfoarray['username'];

Theres 2 equal signs..

why can't he just do $this->username = $this->userinfoarray['username'];  ?

View Replies !
What Function Make When Reading File It Reads Binary Data And Not Normal Strings?
I mean what function make when reading file it reads binary data and not normal strings? and what kind of way you can read a file in whole? because sometimes you don't know how big a file is, like outside the original server.

View Replies !
Making Fields Equal
I have two tables in a database and I have an html form. The tables both include a field called id# and that's how I have linked the tables in my SQL statement. I would like to set up my form so that when someone enters an id# it will write the value to the id field in both tables. Does anyone have any idea how I'd go about doing this?

View Replies !
How Can One Variable Equal 2 Things?
I'm having a problem that is baffling me... say I set a session variable
as so:

$_SESSION['temp'] = "default";

Now if I test the following two conditionals:

if($_SESSION['temp'] == "default")

and

if($_SESSION['temp'] == 0)

they both return TRUE. I don't understand why this is... if anything, I
would have thought testing if it == 1 would be a boolean true since the
variable exists and is not NULL, but testing if == 1 returns FALSE.

View Replies !
Display A Div Only If A Value In Database Is Equal To 1
Im trying to get a div to to only display if the the row in the database called "stock" is equal  to "1" if it is equal to "0 " then do not display the specific div.
Here is the code:

View Replies !
Two Variables, Equal Values - ?
After seeing a script programmed by a user in the beta-test section, I copied its premise - a man vs. dragon battle, with random damage being done.

It just takes random numbers each time the page loads for damage values. That's all it does. However, whenever I play it, the end HP for both man and dragon are exactly the same.

I need 2 things done, or at least to know how to do them -

1) I need to know how to fix the equal-HP problem
2) I would like it if someone could tell me how to achieve the effect of a
<br>...tag within a PHP script.

Here's the script! Code:

View Replies !
Add Two Times Together To Equal A New Time
I am trying to add two times together to equal a new time. I have the following

$Arrive = 03:45:00
$duration = 00:30:00

$depart2 = date("H:i:s", strtotime("+1 hour".$Arrive));

$depart2 would now be 04:45:00

how can I add the duration to this number to give me the final time of 05:15:00 .

View Replies !
Equal Ratio Image With Netpbm
I'm trying to modify a script I am running for a gallery application. The script creates thumbnails properly, but only changes it based on width, which is a variable supplied in a sql table. I'm trying to modify the script so that it so that the width "and height" are no greater than that variable. Here is what I have so far:

Code:
<?php
function RatioResizeImg($src_file, $dest_file, $gid) {

list($dbconn) = pnDBGetConn();
$pntable = pnDBGetTables();
$column = &$pntable['meg_categories_column'];
$query = "SELECT $column[thumbwidth] from $pntable[meg_categories] WHERE gallid=$gid";
$result = $dbconn->Execute($query);
list($newWidth) = $result->fields;
list($newHeight) = $result->fields;

switch(megConfigGetVar('imageSoftware')) {
case 'GD': return RatioResizeImgGD($src_file, $dest_file, $newWidth); break;
case 'ImageMagick': return RatioResizeImgImageMagick($src_file, $dest_file, $newWidth); break;
case 'none': return $src_file; break;
case 'browser': return 'browser' break;
case 'NetPBM': return RatioResizeImgNetPBM($src_file, $dest_file, $newWidth, $newHeight); break;
default: return $src_file; break;
}
}

function RatioResizeImgNetPBM($src_file, $dest_file, $newWidth, $newHeight) {
/* Define where to find the various external binaries we need */
$netpbm = megConfigGetVar('netpbmPath'); /* default: home/www/pcmodeler/netpbm */

$djpeg =$netpbm."/djpeg"; /* decompresses a jpeg to ppm */
$cjpeg =$netpbm."/cjpeg"; /* compreses a ppm to jpeg format */
$pnmscale = $netpbm."/pnmscale"; /* scales a ppm image */
$pnmscale = $netpbm."/pnmscale"; /* scales a ppm image */
$jpgtopnm = $netpbm."/jpegtopnm"; /* convert a jpg to ppm */
$giftopnm = $netpbm."/giftopnm"; /* convert a gif to ppm */
$pngtopnm = $netpbm."/pngtopnm"; /* convert a png to ppm */
$ppmtojpg = $netpbm."/ppmtojpeg"; /* convert a ppm to jpg */
$ppmtogif = $netpbm."/ppmtogif"; /* convert a ppm to gif */
$ppmquant = $netpbm."/ppmquant"; /* colour quantize a ppm */

/* $imginfo = @getimagesize($src_file);
if ($galleryvar['imageSoftwarePath'] == '')
$cmd = $galleryvar['imageSoftwarePath']."/";
else
$cmd = "";
*/

if(!file_exists($dest_file)) {
if(ereg(".gif$",$src_file)) { /* Look for .gif extension */
exec("$giftopnm $src_file | $pnmscale -width $newWidth ".
"| $ppmquant 256 | $ppmtogif -interlace > "$dest_file"");
} elseif(ereg(".jpe?g",$src_file)) { /* Look for .jpg or .jpeg */
exec("$jpgtopnm $src_file | $pnmscale -xysize $newWidth $newHeight".
"| $ppmtojpg > "$dest_file"");
} elseif(ereg(".JPE?G",$src_file)) { /* Look for .JPG or .JPEG */
exec("$jpgtopnm $src_file | $pnmscale -xysize $newWidth $newHeight".".
"| $ppmtojpg > "$dest_file"");
} elseif(ereg(".png",$src_file)) { /* Look for .png */
exec("$pngtopnm $src_file | $pnmscale -xysize $newWidth $newHeight".| ".
"| $ppmquant 256 | $pngtopnm > "$dest_file"");
} else { /* not a GIF, PNG or JPG file */
return("");
}
}
return $dest_file;
}

?>

So far, I can't get it to modify the width, so that portrait images are no larger than the variable. What am I missing?

View Replies !
Equal Height Columns With 1px Border
I need content boxes equal height with 1 px border, i tried this one http://www.positioniseverything.net...ple/equalheight , but i think it doesnt work standard for a 1px border, is it a good idea to measure the text with php to solve this?

View Replies !
A Variable Equal To An External TXT File...
I'm Learning PHP and I would like to know if there's a way to set a variable to an external txt file. If this possible? How can I accomplish this?

View Replies !
Return Only The Records That Are Between Or Equal To The Two Dates
I have a MySQL table with the date stored in three fields as string values like this.

str_yy str_dd str_mm
------------------------
05 01 04
05 02 04

I have a user input "from" and "to" date fields that are also string values ("04/01/05" and "04/20/05") I need to return only the records that are between or equal to the two dates. Being new to MySQL and PHP I am not sure if I should do this with code or with query.

View Replies !
Php With Xml - Substitute A Tags Content And To Write Another Equal One
php can be used with xml right? but i need to use php to both substitute a tags content and to write another equal one (with diferent content) in the side of another.

View Replies !
Show A Message, If The 'status' Column Does Not Equal 'admin'
I want to look in a DB table called 'Member' for the user session and look at a column named 'status'. If the 'status' column equals 'admin' I want to show a message, if the 'status' column does not equal 'admin' I want to show a different message.

I think I am on the right track but it's not working right. The user that I am looking up IS an 'admin' but this code is showing  'message for non-admin' instead of the admin message.

$sql = "SELECT status FROM Member WHERE loginName='{$_SESSION['MM_Username']}'";
if ($sql == "admin") {
echo 'message for admin';       
} else {
echo 'message for non-admin';
}

View Replies !
String Contains Function
Is there a function in PHP that will return a boolean if a String
contains another given String. As what I am trying to do is disallow
input that contains ../ or something else that would allow directory
traversal.

View Replies !
String Function
how to split a string in two string in php, is there any string function for this? EX. i want to brake a name in to first and last name (eg, Heeren Tana, fname=heeren and lname= tana ), please help me , i am creating a search form for searching by either fname or last name or by both name.

View Replies !
Make A Site That Can Take In A String As The Sub Domain For The Site
I am trying to make a site that can take in a string as the sub domain for the site. For example, if you put in, Jenny.homepage.com, the site would get Jenny as a parameter. Does anyone know how to do this?

View Replies !
Multi String Function
I am trying to create my own template engine.. nothing serious just for personal use but I want to make a certain function that I do now know how to make.. basicly it should work like this template($templatename, $var1, $var2, $var3);

though the $var's will be different each time, so with one template it'll only be one var and with another 5.. and I have no idea how to get that done. I want the function to get the template from the database and convert [var1] to $var1 etc.

View Replies !
String 'starts With' Function
I have looked at the PHP string functions and I cant see any function to
check to see whether a string starts with a certain letter or letters. Is
there any way of doing this with the built in functions?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved