-
Posts
1,216 -
Joined
-
Last visited
Everything posted by WebStyles
-
What is the easiest way to make this function
WebStyles replied to Bl4ckMaj1k's topic in PHP Coding Help
$arr_to_string = 'Item, quantity ' . implode(' , ',$arr); implode basically takes all values of an array and glues them together with thatever text/simbols you want. in this case, they're being joined by [space][comma][space] defined in single quotes, thus: ' , ' -
What is the easiest way to make this function
WebStyles replied to Bl4ckMaj1k's topic in PHP Coding Help
this: $quantity = (!empty($_POST['quantity'][$key])) ? intval($_POST['quantity'][$key]) : 0; is shorthand for this: if( !empty($_POST['quantity'][$key]) ){ $quantity = intval($_POST['quantity'][$key]); }else{ $quantity = 0; } -
file_put_contents(); // sorry, another typo. I'm kind of dyslexic today.
-
One link, multiple destinations that are defined? (newbie)
WebStyles replied to qxonn's topic in PHP Coding Help
yeah, that's why i was trying to find another criteria. adding that database id is fine, but then you have to map 85,000 products. -
sorry, I meant file_get_contents();
-
$file = get_file_contents('filepath/filename.txt'); $lines = explode("\n",$file); // now you have an array with all the lines in it. You can loop through it and do whatever you want. foreach($lines as $line){ ... } // erase file: get_put_contents('filepath/filename.txt','');
-
One link, multiple destinations that are defined? (newbie)
WebStyles replied to qxonn's topic in PHP Coding Help
hmmm, 15 forms for 85,000 products. How is this form distinction decided? by category? by type? by country? something else? (there's gotta be something). Imagine there is a category (or 15 in this case) it would be as easy as having the form files with the same name as the respective category. Really depends on what other data you have in each product. -
could it not be that you have a margin or padding on the footer css? (just a suggestion, 'cause I can't see the css files) . Just as a note, I noticed you use: include 'news/index.php'; // single quotes, no parentheses and then include("footer.php"); // parentheses and double quotes. not that it's harmful in any way, but why the 2 different styles of programming?
-
If I'm not missing anything, that seems like it should work fine, unless the function the_permalink(); is also generating html code instead of just echoing a link. I would have a look at that function. remove everything else and just echo that function to see what it outputs.
-
It kind of depends on how large your database is, how much stuff you'll be doing, how long the database connection will be open, and how many simultaneous connections vs how much traffic you have.
-
I'm assuming you got that error on an INSERT or UPDATE command. Check your field names and compare with database, check the values you're inserting, and check for misplaced commas etc.
-
Sure, but all this depends on how many times you'll be using these functions, how your database is set up, if you'll be calling these functions separately from other places, how many records your database has, etc... Only you know exactly how your project is set up, so you're the best person to decide how to implement it.
-
if you use time() all you need to do is substract endTime - startTime and you'll get the result in total seconds.
-
Storing a unique list of strings in an array
WebStyles replied to etrader's topic in PHP Coding Help
there's really no advantage in doing this with txt files, I would use a simple database with a uniqueID and a text field, but, if you insist: you can use a seperate file just to store the last id used, so it's easier to grab and increment: $lastID = file_get_contents('lastSearchID.txt'); $lastID++; file_put_contents('lastSearchID.txt',$lastID); or you can read the last line of your main .txt file, grab the id, increment it and then use it for next search. If you have many simultaneous connections, anticipate file_lock problems when two people are trying to write to it at the exact same time, etc. A Database is much better and faster for this. If you just write a small function to store the search string, the ID will be automatic function storeSearchString($string){ $conn = conn(); mysql_query("insert into `searchTracking` (`searchString`) values ('$string')",$conn); @mysql_close($conn); } hope this helps -
can't really go through all of your code right now, but the first error should give you a hint. "No such file in directory" If the function cannot find the image, it's probably not being uploaded correctly or has a different path or name. After uploading, check the upload folder to see if it's there. Then check that the filename and path match the ones you wanted. If not, there's a problem either uploading, or moving the uploaded file. Hope this helps
-
of course, you could consider using awstats or even google analytics to get that information. Your main problem will not be storing the start time. you can use the unix timestamp for that time(); to store the exact time a user logged in. The hard(er) part if figuring out when the user left, if they just close the browser, or navigate away instead of hitting the logout button, you have to do constant checks at given intervals to check if they're still online or not. So there will always be a margin of error, the same size as your interval for checking.
-
yes, that is an option. Consider organizing each query into a separate function, for re-using. here's a simple example just to illustrate the concept: create a file called functions.php, and put all the functions in there. then add require_once('functions.php'); to all pages. function getNames($id){ ... return $result; } // then this function can be called from any page with: $allnames = getNames($_POST['id']); after that, if your result is an array, you can just use a foreach() loop to skim through all the results and display them.
-
still, I don't get what the problem is. If you know how to get data from one table, you also know how to get it from another.
-
so, what is not working? If you're posting here, I'm assuming you still have a problem to fix. what is it?
-
ok, so what is not working now? (I would remove 'width="219" height="190"' from the <img> tag. if you have different size images in database, that can distort them.)
-
there's nothing to it. Store stuff in session, retrieve stuff from session. keep session_start(); at the beginning of each file and you should be ok.
-
you could also build little translation arrays. Meaning: all the possible words for each placeholder (depends really on how many there are, if they're only a few, this could work fine). Like: $similar1 = array("event","competition","match","game"); then, when you grab a placeholder name, you search through the arrays looking for it. If you use position [0] as your default name, then you can easily translate them. If there are a lot, you can build a simple database with `defaultWord`,`similarWord` and just search through that. again, not the best way to solve your problem, but it should work.
-
let me see if I get it... you want to execute html code from a single jpeg file? As in, use php to create a jpeg file, that you can then send as a little standalone application that will execute it's very own html upon arrival to it's destination?
-
for pictures, you can store the filename in the database and use that to create a link to the file. Imagine you have a database field called `mainPhoto` and the value is 123.jpg. when you pull out the data from the table, also grab `mainPhoto`. then you would display it by simply building a link to the file: <img src="imagesFolder/<?=$mainPhotoFileNameVariable;?>">
-
if the differences are just the 2 you described (uppercase/lowecase and the fact that one says 'v' and the other says 'vs'), then just for the sake of comparison you could convert them all to lowercase and do a replace of all 'vs' str_replace(" vs "," v",$file_contents); Of course, this is just a silly fix, and also depends on how you're importing the data (string or array). a unique id per event, as you said, would be much better and easier to identify.