-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
help echoing exploded array .... PLEASE Help!!
mikesta707 replied to YoungNate_Black_coder's topic in PHP Coding Help
There is a complimentary function to explode called implode(), which does basically the opposite of explode. You give it an array, and a delimiter, and you get back a string. For example $array = array("attribute1", "attribute2", "attribute3");//example output that would be in your $het array //lets say we wanted our string to be like this: attribute1, attribute2, attribute3 //we could use ", " as our delimiter $string = implode(", ", $array);//Output: attribute1, attribute2, attribute3 //we could also use" - " if we wanted $string = implode(" - ", $array);//Output: attribute1 - attribute2 - attribute3 You can use anythign as a delimiter. If you wanted to have them each on a separate line you could use <br />. If you wanted something more complicated, like as list items (<li>'s) then let me know, as its slightly more complicated, and I'll give you a hand Implode: http://php.net/manual/en/function.implode.php Hope this helps -
I'm not entirely sure what you mean by flashing white. Do you mean when the browser window goes white before loading the page fully? Because I'm pretty sure that happens on all webpages.. Would you mind clarifying your question
-
password can only be changed when a particular field has data entred
mikesta707 replied to Doug's topic in PHP Coding Help
Ok, well the problem lies in the fact that you try to update all the fields even though they may not be filled out. This produces an error with age, but with the other fields, if they are empty the users row date will be overwritten with that empty data. What you need to do is find out which fields were left empty, and dynamically build you query so you leave out the empty fields from the update query. SO instead of writing $query = "UPDATE registration SET first_name = '$first_name', last_name = '$last_name', username = '$username', gender = '$gender', " . " email = '$email', password = '$new_password1', picture = '$new_picture' WHERE user_id = '" . $_SESSION['user_id'] . "'"; regardless of what is set and not set, you want to have some conditions (like if (empty($age))), which will change your update statement. -
yes indeed. Happy fathers day to all the fathers out there.
-
Wow nice, thats a cool story. Maybe if you had become his apprentice you'd be a famous tattoo artist now haha. But I think wed all miss you at phpfreaks if you did. Do you have anymore or is that the only one you've gotten? Do you still design tattoo's?
-
You have a syntax error. You are trying to use double quotes inside a double quotes string echo '<embed flashvars="" src="http://www.salmobile.info/scrubber.swf?file=http://www.salmobile.info/sab/1/'.$player.'&bufferTime=3&previewImage=http://salmobile.info/sab/img1/'.$image.'&startAt=0&autoStart=false" allowfullscreen="true" type="application/x-shockwave-flash" id="FLVScrubber2" style="width: 323px; height: 283px;" />'; EDIT: didnt notice you have variables. Gotta concatenate
-
why not just put the value in a hidden field in the form
-
password can only be changed when a particular field has data entred
mikesta707 replied to Doug's topic in PHP Coding Help
Ok. A couple things. When posting code, only post the relevant code. No one wants to wade through lines and lines of script just to FIND the code that is giving you problems. Please don't just copy and paste your entire page next time. Anyways, this code: if (!$error) { if (!empty($first_name) && !empty($last_name) && !empty($username) && !empty($gender) && !empty($email)) { // Only set the picture column if there is a new picture // Only set the password in there is a new one if (!empty($new_picture)) { if (!empty($new_password1)) { $query = "UPDATE registration SET first_name = '$first_name', last_name = '$last_name', username = '$username', gender = '$gender', " . " email = '$email', password = '$new_password1', picture = '$new_picture' WHERE user_id = '" . $_SESSION['user_id'] . "'"; } } else { Is this the code block that is giving you trouble? What happens when you don't enter in the age? Blank page? an error? Script just doesn't do anything? Is there any feedback from your script (IE one of your error messages pop up) if you don't already have error reporting try turning it on all the way by putting the following at the top of your page ini_set('display_errors',1); error_reporting(E_ALL); -
Showing Image from directory using mysql field?
mikesta707 replied to amg182's topic in PHP Coding Help
Just so you know, the php bracket syntax is for when trying to interpolate array/object values in a string, IE $array = array(array with some key value pairs); echo $array['someKey'];//brackets are not needed here echo "Some string stuff and the array: $array['someKey']";//this will not work brackets are needed echo "Some string stuff and the array: {$array['someKey']}";//now this will work. brackets are necessary here If you are wondering why, its because when using an array in a string, without brackets it becomes ambiguous //php doesn't really know $array is an array until run time //so this is ambiguous echo "some stuff plus $array['key']"; //PHP doesnt know if $array is a single variable value. or an array yet //$array could have a value of say.. "hello" //php doesnt know if we want the string to say "some stuff plus hello['key']" //or do we want the value of $array at the key 'key' (say that valye is goodbye //so the string could say "some stuff plus goodbye" -
nice. Kinda puts mine to shame haha.
-
CURL - tell remote server javascript is enabled?
mikesta707 replied to kiss-o-matic's topic in PHP Coding Help
After a quick google search, I came up with the following And I am inclined to believe what this poster is saying is true. Sorry, but I don't think their is a way to "spoof" javascript being enabled with curl -
Ok. There are a couple problems. TO preface the explanation, let me give you some advice. When debugging code, and specifically mysql query related bugs, it is best to make PHP as helpful as possible. By helpful, I mean it will tell you when an error is happening, and what the error is (and more information if able). For example, I assume the query giving you problems is: $mainimgq=mysql_query("SELECT ".$mainimg." FROM users WHERE user_id='".mysql_result($searchq,$i,"user_id")."'"); PHP doesn't alert you of mysql errors unless you tell it to. In our case, the easiest way for php to tell us is to use an "or die()" statement. Note: or die() is fine for debugging, but when your product is live, it is imperative that you handle errors more gracefully. So, we can use or die() like this $mainimgq=mysql_query("SELECT ".$mainimg." FROM users WHERE user_id='".mysql_result($searchq,$i,"user_id")."'") or die(mysql_error()); What that will do is show the mysql error when the query fails. Now, we might also benefit from seeing the whole query as well as the error. we can do that by storing the query in a variable, and adding it to the die clause, like so $query = "SELECT ".$mainimg." FROM users WHERE user_id='".mysql_result($searchq,$i,"user_id")."'" $mainimgq=mysql_query($query); or die("There was a problem with the query: " . $query . "<br />Error: " . mysql_error()); Now, onto your problem. In your query you do $mainimgq=mysql_query("SELECT ".$mainimg." FROM users WHERE user_id='".mysql_result($searchq,$i,"user_id")."'"); and you use $mainimg as a column name. This doesn't really make sense because this is a column value in the user table you get from your first select statement. I assume this is the name of the users image. I also assume you don't have column names that are based of the name of a users (presumably uploaded?) image (please correct me if i'm wrong) I don't really understand what you are trying to accomplish here. From the looks of it you can do what you want with 1 query (your second query doesn't really make any sense at all, no offense). Can you explain what the code you posted is supposed to do? Also can you tell us what happens when you run this script? Blank page? Error?
-
Converting UNIX Timestamp to regular Date display
mikesta707 replied to Ernie_73's topic in PHP Coding Help
you can use the date function: http://php.net/manual/en/function.date.php The second parameter accepts a unix time stamp. Check out the manual page for how to format it like you want, but here is an example $dateFromTimestamp = date("F j, Y, g:i a", $timestamp); // March 10, 2001, 5:16 pm (for example) -
looking for social networking or dating script/software
mikesta707 replied to kevin32's topic in Miscellaneous
After a quick google search, I turned up http://www.socialengine.net/ (paid, but there is a trial) http://www.phpfox.com/ (paid: 90$) And this link has a list of them, paid and free (the second one down is open source, and is highly rated) None of these scripts said anything about mobile support, though I imagine at least the paid ones would have something. I did very little research on these guys, and have never used them so I cannot attest to the veracity of any of these. Hope this helps -
Add/Subtract one second from date("Y-m-d H:i:s");
mikesta707 replied to jmurch's topic in PHP Coding Help
You can add a unix timestamp into the second parameter of the date() function in order to use your own time stamp and have it formatted via date.. In this case, your own time stamp would be the current time minus 1 second. You can get the current time stamp using the time() function. So if we do $time = time() -1;//time stamp is in seconds, so now -1 would be the current date minus 1 $now = date("Y-m-d H:i:s", $time); Hope this helps Edit: Ninjad by xyph, but I believe xyph mean to use time() instead of timestamp() (correct me if I'm wrong) So im posting anyways -
Are you asking for someone to code this for you? If so, this is a PHP help forum, not a PHP "Hey do this problem for me kthxbye" forum. If you are interested in hiring someone to do this, there is a freelance forum you can post an add on. Otherwise, we aren't going to just code something up for you. Especially something is complex as what you are asking. What I suggest you do is a little research to see what you need to do/learn in order to complete this project. Once you know what you have to do, you can get started, and when you run into problems, then you can post here for help. I don't know of any tutorials off hand, but if you try some google searches for recording webcam video via flash, that would be a good start. THen you can research into how flash can talk to PHP (send data to flash from PHP and send data from PHP to flash). Once there, its a matter of using the S3 API to store the video you recorded. EDIT: Oh sorry, I had a brain fart. Totally thought this was the PHP forums, not the miscellaneous forums, so sorry for being a little more harsh than was warranted. However, the point remains the same EDIT2: Oh this was ninja moved while I was typing up the response. Disregard first edit.
-
Truncating a string at a space and not in the middle of a word
mikesta707 replied to Gutspiller's topic in PHP Coding Help
You get "Cannot redeclare XX function blah blah... " errors when you... well... redeclare a function. What that means is you must have another function names truncatestring(). Perhaps in an included page or something. Also, just as a coding style preference, I like to put my functions at the top of my page, rather than at an arbitrary point in the middle of the script. Makes it a little easier to find as you add more and more code and functions to your page. Not saying what you have is bad/incorrect but just wanted to let you know -
So I got my first tattoo earlier today. Its a tiny one I got on my wrist for 30 bucks (yeah I'm cheap lol). Was wondering if any of you guys got tattoo's? If so what was your first one (and if you don't mind saying, how much did it cost?). If you have more than one, whats your favorite? Did you get it done by a famous tattoo artist in your area? Were you plastered when you got it (lol)? Did it hurt really bad? worse or better than you expected? I've been wanting one for a long time now and though its definitely not my "dream" tattoo, I think its a good starter one. Get me used to the how much it hurts (I expected it to hurt a lot more than it did). Lemme know what you guys think! pic related. my tattoo [attachment deleted by admin]
-
Yeah the script kiddy requests come in waves
-
Oh I see. Sorry I misunderstood. This is the PHP baord. You may want to try posting this in mysql help
-
How are your tables structured? When you say each location can have more than 1 architect, how do you store the multiple architects? Are they each in their own row with matching locations?
-
If you are gaurenteed that your URL's will always look like that, simple string manipulation would suffice. This is what I would do $str = strtolower($url);//convert it to lower case $str = $str_replace("http://");//remove the http:// part at the beginning $pieces = explode("/", $str); $size = count($pieces);//get count $directory = $pieces($size-2);//get the directory right before the numbered file name You could also do a regular expression search, but I don't see the point if you can use simple string functions
-
You can only use implode on an array. Implode takes an array and returns a string with all the elements put into a string separated by the delimiter you pass on. You are passing in a string, this why you are getting your error. Now, as for your problem. I don't quite understand what you are trying to do. Could you perhaps explain your problem more clearly
-
I'd suggest XNA with C#.NET i, it's a great starting point imo. I found Unity to be allot more 'IDE' and 'game design' orientated and not allot of hardcore coding going on. XNA is a pretty good starting point. If you read a few tutorials (and the documentation microsoft has for it is pretty good) you can make some 2d games in a matter of hours. I would suggest starting with 2D games so you can get your feet wet and have some experience with some of the simpler mechanics involved with game creation (tracking movement of objects, drawing to the screen etc.) Once you have these things understood, you can move on to the more complex game making topics, (like the ones Ignace mentions, or algorithms for finding the best path/optimal solution from a starting point to a goal, etc.). But just so you know, making games isn't as easy as you may thing. There are some concepts and problems you will encounter that just don't come up in languages like PHP/Javascript or web development in general, that you will come across alot in game development (this is one of the reasons I suggest starting with simple 2D games) The Best starting point would probably be to implement a pong or brick attack game, so you have some experience with position tracking/bouncing/collision which are pretty core concepts. Then move on to different simple 2D games, and perhaps make up your own, or add new/different features to an old game you are implementing
-
To add to what pikachu said, when trying to figure out mysql errors, it is usually helpful to output the query when the mysql fails. For example $result = mysql_query($sql) or die("There was a mysql error: " . mysql_error() . "<br />On the query: " . $sql); Or die is kind of a touchy subject, as its not good practice when your site is live, so you will want to switch to a more elegant solution to handling errors, but while debugging this is a great tool. It allows you to view the query as its been sent, and what the error is. This allows you to catch simple syntax errors like yours.