-
Posts
476 -
Joined
-
Last visited
Everything posted by xProteuSx
-
[SOLVED] Scientific Notation to Regular Integer
xProteuSx replied to xProteuSx's topic in PHP Coding Help
$row[0] = 1e+06; $formattednumber = (int) $row[0]; echo $formattednumber; Output: '1' -
[SOLVED] Scientific Notation to Regular Integer
xProteuSx replied to xProteuSx's topic in PHP Coding Help
Sorry, I should have mentioned that not all number are in scientific notation. If I use the method you have outlined, it screws up all non-scientific notation numbers. -
One of the columns in my database takes large integers. When they are input MySQL or PHP condenses the numbers to scientific notation, so if I output the field I get output such as: '1e+06'. Is there a PHP command to revert the number so that instead of 1e+06 I get 1000000?? Thanks.
-
Thanks very much for all the replies. I have incorporated urlencode() and urldecode() into the page, and it works beautifully, so thanks MadTechie. premiso, thanks for your idea. I can see that it would work. However, after having consulted the PHP manual for urlencode() and urldecode() this was the simplest route for me. Thanks anyways. I love this site. Thanks guys.
-
Yeah, sorry, ofcourse. The only thing is that I cannot have fillers like this at all. I need actual spaces in there because in most instances I use that database to output the data as plain text, and not html, and if I replace spaces with %20 then all text will contain this html.
-
I have something that looks like this: <a href="http://www.mysite.com/nation.php?country=Bosnia & Herzegovina"> The country listing at the end of the link is generated out of a database. Ofcourse, this doesn't really work. I can't have spaces in the link, but that is how the names have to be in the database. Is there any php command, or series of commands, that can help me get around this without having to insert '20%' into the link? Because 'Bosnia & Herzegovina' is really a value from a database, and for other reasons, I can't have 20%'s in there. Thanks.
-
In the end, this worked for me: $query = "UPDATE rb_notes SET image_thumb='$thumbpath' WHERE id_notes='$idthumb'";
-
Yesideez, I know what you are saying. I fixed up the query, and I printed the value of $id one line before the query, and it is not NULL. I really don't know what i going on. DarkWater, I have NEVER seen mysql code being executed like that. Mind you, my PHP texts are from the late nineties, I think. Can you recommend a good site on SQL syntax in the way you have shown it? I haven't even come across that sort of code on the internet, and God knows I have done many searches and read a few articles.
-
Yesideez, Then I guess that I have to use update instead of insert, because I have to manipulate certain rows only (as in id=6 or whatever). At the moment I am trying this, but am having no luck: $query = "UPDATE SET rb_notes image_thumb='$thumbnail' WHERE id_notes LIKE='$id'"; Error in query : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET rb_notes image_thumb='/uploads/thumb/200.jpg' WHERE id_notes LIKE=''' at line 1 Really strange, considering that if I do this: echo $id; I have a value returned to me.
-
I cannot get this MySQL query to work. My code is as follows: $id = mysql_real_escape_string($_GET['id']); //does return the proper value when I use echo command to display $query = "INSERT INTO rb_notes(image_thumb) VALUES ('$thumbnail') WHERE ID LIKE $id"; Error I get is as follows: Error in query : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE ID LIKE' at line 1 I have tried every variation that I can think of: $query = "INSERT INTO rb_notes(image_thumb) VALUES ('$thumbnail') WHERE ID LIKE '$id'"; $query = "INSERT INTO rb_notes WHERE ID LIKE '$id' (image_thumb) VALUES ('$thumbnail')"; $query = "UPDATE rb_notes(image_thumb) VALUES ('$thumbnail') WHERE ID LIKE '$id'"; etc etc ... Please help!
-
I am not very familiar with arrays. I will admit this right off the bat. I have two textbooks on PHP in front of me, and I can't get my code to work. I am trying to add $row[0] from a DB into the array $country_array. This is my code: $country_array = array(); if (mysql_num_rows($countriesresult)>0) { while ($row = mysql_fetch_row($countriesresult)) { echo $row[0]; array_push($country_array, $row[0]); } } echo $country_array; The line 'echo $row[0];' prints all of the countries I have listed in my DB but the code after that is doing one of two things: 1. I am not adding $row[0] to the array properly or 2. You cannot display an array using the echo function Anyone have any suggestions? Thanks.
-
phpSensei, Just as I thought, that piece of code only lists the letters that the country names start with. Its an interesting piece of code, and I'll see if I can't implement it in combination with other snippets to put together what I need. DarkSuperHero, You're absolutely right. But to me its a complex series of logical steps. Its making my head spin. I guess I will have to do this. I was hoping that someone had devised a 'smart system' because this is something that would, and does, get used often on a site. I'm just trying to stay away from querying the DB 26 times (one time for each letter of the alphabet). Might have to do that in the end. I'll let you all know how I made out.
-
Ok, this is actually more difficult than I thought it would be, but here's the idea: I have a DB with a listing of countries. I would like to display the contents of this DB, but I need to do it in a very specific way. I would like results to look like this: A Afghanistan Albania Algeria .... B Bahamas Bahrain Bangladesh ... C ... Z ... Zimbabwe It is easy enough to sort the entire list as one, without splitting it up under its letter heading. Also, I can sort the countries letter by letter, but this calls for 26 DB queries, and a lengthy segment of code. This kind of stuff gets done all the time. Has anyone done anything like this? Any ideas, pointers, snippets of code for displaying things in this manner? Thanks a mil!
-
Hmm ... I have a bad habit of avoiding arrays, because I have never used them before. I guess that its time for me to learn. After all, they are SUPER important. I will figure this out tomorrow. Thanks for your suggestion (which is probably 100% right).
-
You can escape some characters by putting a '\' in front of them. For example: echo 'You can't do this.'; Would bring up an error, but if you do this, it will work: echo 'You can\'t do this.'; When you view the text it will show up as: You can't do this.
-
I have a DB of countries, and I would like to list them alphabetically, and also by letter heading. I know how to list them alphabetically, and I also know how to list just the A's, B's, C's etc. but I only know how to do this using multiple DB queries. Is there any way to do this with a single query? ... A: Afghanistan, Albania, Algeria, Angola, etc etc B: Bahamas, Bahrain, Bangladesh, etc etc C: Cambodia, Cameroon, Canada, etc etc etc ...
-
redarrow, I did come across that snippet when I was searching the web for ideas. It seems nice and easy, but I can not figure out how to assign input1, input2, and input3 specific names, and also, I need the fields to upload in order. What I mean by this is that if someone fills out field1 and field3, and leaves field2 null, I can't have the file in field3 being uploaded to directory2. Know what I mean? Do you have any ideas for coding this? By the way, I'm not overly familiar with arrays. Thank you for your reply. webmaster, Wow. I will definitely take a look at your code. It will take some time to see whether I can make it work. Thanks.
-
I have designed a database around the idea that I could upload multiple image files with a single form. Now, it seems, I can't figure out how to do this and all my hard work appear to be down the toilet atm. <tr valign="top"> <td bgcolor="#dedede" width="120" align="left"><font size="-1"> Image of Front: </font></td> <td bgcolor="#dedede" align="left"> <center><input type="file" name="notes_image_front" size="27"><br><font size="-2">Max filesize: 150kb. Width must be: 600px. Maximum height: 1500px.</center> </td> </tr> <tr valign="top"> <td bgcolor="#dedede" width="120" align="left"><font size="-1"> Image of Back: </font></td> <td bgcolor="#dedede" align="left"> <center><input type="file" name="notes_image_back" size="27"><br><font size="-2">Max filesize: 150kb. Width must be: 600px. Maximum height: 1500px.</center> </td> </tr> <tr valign="top"> <td bgcolor="#dedede" width="120" align="left"><font size="-1"> Thumbnail: </font></td> <td bgcolor="#dedede" align="left"> <center><input type="file" name="notes_image_thumb" size="27"><br><font size="-2">Max filesize: 50kb. Width must be: 200px. Maximum height: 500px.</center> </td> </tr> This is the form. The php for getting the three values is: $notes_image_front = mysql_real_escape_string($_POST['notes_image_front']); $notes_image_back = mysql_real_escape_string($_POST['notes_image_back']); $notes_image_thumb = mysql_real_escape_string($_POST['notes_image_thumb']); Ofcourse, when I go to submit the form, the three values come back as NULL. I have googled the crap out of 'how to upload multiple files with a single form in php' and have come up with nothing that I have been able to implement. Help please!! You guys have always come through for me before! Thanks in advance.
-
I have designed a database around the idea that I could upload multiple image files with a single form. Now, it seems, I can't figure out how to do this and all my hard work appear to be down the toilet atm. <tr valign="top"> <td bgcolor="#dedede" width="120" align="left"><font size="-1"> Image of Front: </font></td> <td bgcolor="#dedede" align="left"> <center><input type="file" name="notes_image_front" size="27"><br><font size="-2">Max filesize: 150kb. Width must be: 600px. Maximum height: 1500px.</center> </td> </tr> <tr valign="top"> <td bgcolor="#dedede" width="120" align="left"><font size="-1"> Image of Back: </font></td> <td bgcolor="#dedede" align="left"> <center><input type="file" name="notes_image_back" size="27"><br><font size="-2">Max filesize: 150kb. Width must be: 600px. Maximum height: 1500px.</center> </td> </tr> <tr valign="top"> <td bgcolor="#dedede" width="120" align="left"><font size="-1"> Thumbnail: </font></td> <td bgcolor="#dedede" align="left"> <center><input type="file" name="notes_image_thumb" size="27"><br><font size="-2">Max filesize: 50kb. Width must be: 200px. Maximum height: 500px.</center> </td> </tr> This is the form. The php for getting the three values is: $notes_image_front = mysql_real_escape_string($_POST['notes_image_front']); $notes_image_back = mysql_real_escape_string($_POST['notes_image_back']); $notes_image_thumb = mysql_real_escape_string($_POST['notes_image_thumb']); Ofcourse, when I go to submit the form, the three values come back as NULL. I have googled the crap out of 'how to upload multiple files with a single form in php' and have come up with nothing that I have been able to implement. Help please!! You guys have always come through for me before! Thanks in advance.
-
Actually, just had to add this to my .htaccess file: AddHandler application/x-httpd-php5 .html .php .htm This got it working. Thanks anyways.
-
Is there a way to include php code in an html file? What I mean, is, can I still have the .html extension, and not have to change it to a .php file? I have found that if I am working with an html file and include snippets of code in the middle, the code is treated like errant text. Thanks.
-
Great! Thanks for your response. I have it figured out now, and have this working on my site. Thanks very much for letting me know its possible. It saves me time! I've tried things without asking before, only to spend hours and hours of my time trying to do something that can't be done (like trying to get the visitors screen resolution solely through php). lol. Hindsight is a bitch! PHP is server side! Duh! Thanks again.
-
I am trying to figure out whether this is do-able: Login.php has a hidden function (call it 'function-login') which takes 2 variables (username, password). On the original visit to this page, no sessions are loaded hence username=null and password=null. GET username; GET password; if (username==' ' || pass==' ') { display login form with two boxes for username and password action = refresh this page with new variables from the login boxes } else { check that password and username match in DB if (everything checks out) { Yay, you're logged in! } else { You entered a password/username combo that does not exist } } Can this be done? Going from login.php -> login.php? I usually see login.php -> authorize.php -> welcome.php How would I set up a function for this? Many thanks.
-
I am building a site, and I would like it to fit the entire browser window, regardless of whether there is enough content or not. So far it works if there is enough content to fill the window, but I would like the site to stretch regardless. I have been at this for hours, but its my first attempt at CSS: I have been <table> all the way, from the start, and am making the conversion only now. Please help before I pull all of my hair out (it hurts!). INDEX.HTML: <body marginheight="0" marginwidth="0" height="100%"> <div class="fullscreen"> <table height="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <table width="600" height="100%" border="0" cellpadding="0" cellspacing="0"> <div id="header" class="header"> <tr width="600"> <td width="3"></td> <td height="30" bgcolor="#000000" align="right"> <font color="#FFFFFF"><strong> | <a href="http://www.hotmail.com">Stock</a> | <a href="http://www.hotmail.com">Accessories</a> | <a href="http://www.hotmail.com">Specials</a> | <a href="http://www.hotmail.com">Your Account</a> | </strong></font> </td> </tr> </div> <tr width="600"> <td width="3"></td> <td height="1" bgcolor="#666666"></td> </tr> <div id="mainbody" class="mainbody"> <tr> <td width="3"></td> <td height="*" bgcolor="#000000"> </td> </tr> </div> <tr width="600"> <td width="3"></td> <td height="1" bgcolor="#666666"></td> </tr> <div id="footer" class="footer"> <tr width="600"> <td width="3"></td> <td height="30" bgcolor="#000000" align="right"> <font color="#FFFFFF"><strong> | <a href="http://www.hotmail.com">Contact Us</a> | <a href="http://www.hotmail.com">About Us</a> | <a href="http://www.hotmail.com">Disclamer</a> | <font class="small">hotmail<sup>©</sup></font> | </strong></font> </td> </tr> </div> </table> </td> <td align="left"> <div id="sidebar" class="sidebar"> <table> <tr> <td valign="bottom"> <img src="images/smokingcigar.jpg" /> </td> </tr> </table> </div> </td> </tr> </table> </div> </body> MAIN.CSS @charset "utf-8"; html { background-color:#000000; height:100%; } a:link { font-size:12px; font-style:italic; text-decoration:none; color:#FFFFFF; } a:visited { font-size:12px; font-style:italic; text-decoration:none; color:#FFFFFF; } a:active { font-size:12px; font-style:italic; text-decoration:none; color:#FFFFFF; } a:hover { font-size:12px; font-style:italic; text-decoration:none; color:#CCCCCC; } font.small { font-size:12px; font-style:italic; color:#FFFFFF; } div.fullscreeen { display:block; position:absolute; top:0; left:0; width:100%; height:100%; } Thanks a mil to anyone who takes the time! I am at a total loss, and only ask these things after I have tried everything.
-
The '%' symbol is the wildcard in this case ...