premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
[MSSQL] Populate a row with data from another table
premiso replied to bluesoul's topic in PHP Coding Help
INSERT INTO tbl_name (`col`, `col2`) SELECT `col`, `col2` FROM tabl_name WHERE x=x; Should work. If the tbl_name columns matches the ones in tabl_name you can omit the (`col`..) portion and change the select to * instead of defining each column. -
$_SERVER['PHP_SELF'] That might work?
-
[SOLVED] PHP extensioin access internal variables
premiso replied to castis's topic in PHP Coding Help
I kind of figured that was what you wanted. http://www.phpfreaks.com/forums/index.php/board,19.0.html I would direct you there to get your question answered. -
[SOLVED] PHP extensioin access internal variables
premiso replied to castis's topic in PHP Coding Help
What do you mean by extension? And what is the goal/purpose of the extension? -
[SOLVED] How to create a file in a specific directory?
premiso replied to ballhogjoni's topic in PHP Coding Help
Maybe try this: <?php if (file_exists('local/path/to/file/test.csv')) { echo 'The file exists...grabbing the contents<br />'; $file = file_get_contents('local/path/to/file/test.csv'); echo nl2br($file); echo '<br />End of the file!'; }else { $fh = fopen('local/path/to/file/test.csv','w'); fwrite($fh,$csv_output); fclose($fh); } ?> And see what that displays. It may be writing it but for whatever reason you cannot see it?? -
[SOLVED] How to create a file in a specific directory?
premiso replied to ballhogjoni's topic in PHP Coding Help
What error are you getting? Are you using Windows or Linux? -
There ya go, I do not look at the javascript section, I am sure if I did I would have a different take. Either way thanks for writing out your explanation =)
-
lol I fail to see how that is less of a headache...more code = more chance to mess up = larger headache??? But it probably works, so yea. To each their own. EDIT: But it brings up a good point, you could use this instead lol. echo '<input type="image" src="images/login.jpg" id="submit" onClick="document.forms[\'login_form\'].submit()" name="submit" />';
-
lol cannot believe I missed that. On a sidetracked note, I usually set a variable in my php files called "$included" is that variable is not set then nothing is included and the script just dies. It helps prevent the intrusion that Russell was talking about, however that can be overkill, but I like to play things pretty safe when it comes to my site =)
-
I would use constants with define in the settings file for root directory. If it still fails when using that post back and let us know. That way it cannot get overwritten by accident and stays the same throughout the whole script.
-
echo '<input type="image" src="images/login.jpg" id="submit" onClick="document.forms.login_form.submit()" name="submit" />'; The javascript I gave you was bad, chances are you had a javascript error. Try using the above. Again this JS might also be bad, but that is the source of your issue, so yea. If it does not work again, google submitting form javascript onclick and look at their examples and try them.
-
<?php echo "<font face=verdana >"; // put blog data in an array $line = file("blogfile.txt"); $i=count($line); $line = array_reverse($line); for ($n=0 ; $n < $i-1 ; $n++ ) { $blog = explode("|", $line[$n]); if (isset($blog[0])) { echo "namn : " .$blog[0]."<br>"; echo " datum: " .$blog[1]."<br>"; echo " ämne: " .$blog[2]."<br>"; echo " meddelande: " .$blog[3]."<br><br>"; } } ?> http://us.php.net/manual/en/function.array-reverse.php used file cause it is less code and more efficient, then used the above function to reverse the array so the newest message should display on top. Questions let me know.
-
I would change this: if($qry) { to if(mysql_num_rows($qry) > 0) { Then here: echo '<input type="image" src="images/login.jpg" id="submit" name="submit" />'; Your submit button is of type "image", shouldn't this be "submit"...I am not sure on this, so yea... if you want it of type image, maybe try this: echo '<input type="image" src="images/login.jpg" id="submit" onClick="this.submit()" name="submit" />'; So it will actually submit the form onclick. That is why the form keeps displaying, it is never being submitted. Fix that and your form should submit.
-
If $row is coming from the database it was probably retrieved with mysql_fetch_object not third party at all just a different way of pulling data out of the database.
-
Generally passwords should be a 1-way md5 salted hash. If a user forgets their password you use a forgot password form to generate a new random one and email it to them. However there are plenty of encrypt/decrypt functions out there...not as secure as the straight hash they work... Encode: base64_encode Decode: base64_decode Would be the easiest/cleanest without any extra code to add to make it work. http://www.phpbuilder.com/board/showthread.php?t=10326721 There is a thread with someone who built one, you may want to use that, I do not know. Googleing "php encrypt decrypt" will pull up other scripts so you can choose. Any type of encryption can be cracked, so I highly suggest you re-think your logic and use the md5 salted hash.
-
Question about Query pulling from Several Tables
premiso replied to limitphp's topic in PHP Coding Help
I would actually re-think your vote table. Do you really need songName in there if it links to the song table? No not really, you are just duplicating data which is not necessary... -
[SOLVED] How do I display just the year with a datetime field?
premiso replied to limitphp's topic in PHP Coding Help
ummm....see above? -
imo, Use jQuery. http://t.wits.sg/2008/06/20/jquery-progress-bar-11/ http://plugins.jquery.com/project/jQueryProgressBar The progress bar is basically done for you, just have to tweak it to suit your code. However, if available, flash uploaders are very nice.
-
[SOLVED] How do I display just the year with a datetime field?
premiso replied to limitphp's topic in PHP Coding Help
Just a side note for you limit, pulling it out of MySQL in the correct format is the preferred way as it is more efficient and produces much less code. If you want to add more code, I would go with flyhoney's way. Just an fyi =) (Why write code to process it when you can pull it out exactly how you need it?) -
Question about Query pulling from Several Tables
premiso replied to limitphp's topic in PHP Coding Help
You need to declare at is tablename.songName, what I would suggest doing is changing the column name as such: $sql = "SELECT songs.*, vote.*, vote.songName as vtSongName, songs.songName as snSongName FROM vote, songs WHERE vote.ArtistID=$artistID AND songs.songID=vote.songID"; I am not sure if that works or not, I would actually define all columns you are using instead of using * but then you can access either one with vt or sn in front of "songname" EDIT: Thinking about it, why do you have SongName in both tables? The vote table should link to the song table via the songid, you should not duplicate data like that... -
[SOLVED] How do I display just the year with a datetime field?
premiso replied to limitphp's topic in PHP Coding Help
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format SELECT date_format(`datefield`, '%Y') FROM table_name -
PHP has no clue/does not care what the page displays as or looks like. You can however pull an image name out of the database and generate the CSS/HTML for it to display how you want it to. But you do not necessarily need PHP to do this. You can create a static html page with 2 known image names and create that effect. Which is the route I would tell you to go for now. Create the actual HTML/CSS first, then take that and plug it into your PHP.
-
<?php $newTime = time()+3600*24*2; // todays from now. $timeLeft = $newTime - time(); echo date('d', $timeLeft) . " days left"; ?> That probably will not get you the exact results but it is a start. You may want to look into strtotime also.
-
"an got query error" How does that help? Change this: mysql_query($query) or die('Error, query failed'); to mysql_query($query) or die('Error, query failed!<br />' . mysql_error()); And report back that error.
-
Why are you adding slashes? Try removing the add slashes and sees what happens. If you need to escape it use mysql_real_escape_string over add slashes.