
Vitamin
Members-
Posts
88 -
Joined
-
Last visited
Never
Everything posted by Vitamin
-
Can't echo / output anything before a header statement. It is a sticky on this forum too. http://www.phpfreaks.com/forums/php-coding-help/header-errors-read-here-before-posting-them/
-
mjdamato, thanks a ton for all your help. Going to go give it a try. Everything you said makes perfect since!
-
Ah thanks for the explanation. I took a database design and theory class and that looks like it was right from it (Kinda wishing I still had the Book ) So now my next problem is say there are 50 hobbies in the hobbies table and say Bob has 20 hobbies and Dave has 25 hobbies. So wouldn't that table get really big really quick? Especially if there is a user being added every couple minutes. Going to step away for a couple hours so if I don't respond sorry. Sorry this is turning into a SQL problem more then a PHP problem so it's in the wrong forum :\
-
There are plenty of tutorials on the web doing just this thing. Just went and looked at a few and it seams this is how you do it. $tmpName = $_FILES['image']['tmp_name']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); Then insert $content into the database. Did not try it but here is where I got it from. http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-mysql-database.aspx
-
Thanks for the replay. One more question. You say "If you must use serialize() on an array" do you say that because there is a different way to put that array in the database? I was always under the impression that that was the only way.
-
To store a image in a database you have to use the data type BLOB. I have never experimented with it, but I've seen this question come up on the forums quite a bit and in almost all cases the answer is to store the image in a directory on your server and save the file path in the database.
-
I want to store a array in a database using serialize(), but I want to know how many bytes the array is going to be so when I create the database I can decide on what type of field to use. I have always used longtext (basically because I did not know any other way) in the past, but that can go up to 4GB of data and there is know way that the arrays I will be storing with be even close to 4GB. Also does anyone have a good tutorial about storing arrays in databases?
-
The problem is that for each shopping list you want to display you have to have a list of items that are say on list 1, but the items on list 2 are going to be different then the items on list 1. So you will need another table to keep track of what items are on which list. To fix what you are working on now you should be able to do the following. $sql2=mysql_query("SELECT catid, category FROM cat WHERE listid=$id") or die("cannot select: ".mysql_error()); $sql3=mysql_query("SELECT itemname, itemid, catid FROM items") or die("cannot select: ".mysql_error()); //you want to get the items.catid while ($res2 = mysql_fetch_array($sql2) { echo $res2['category']; while ($res3 = mysql_fetch_array($sql3) { if $res2['catid'] == $res3['catid'] { echo $res3['itemname'] } } } I think that should work, but ever list is going to have the same items on it.
-
$weekdays = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); echo current($weekdays) . "<br />"; $i = 0; while ($i < count($weekdays)) { echo next($weekdays) . "<br />"; $i++; }
-
Oh sorry I miss under stud what you were trying to do. Try something like this $sql2=mysql_query("SELECT catid, category FROM cat WHERE listid=$id") or die("cannot select: ".mysql_error()); $sql3=mysql_query("SELECT items.itemname, items.itemid, cat.catid FROM items, cat WHERE cat.catid=items.catid") or die("cannot select: ".mysql_error()); while ($res2 = mysql_fetch_array($sql2) { echo $res2['category']; while ($res3 = mysql_fetch_array($sql3) { if $res2['catid'] == $res3['catid'] { //im not exactly sure if i have this right, but you should be able to figure it out echo $res3['itemname'] } } }
-
I did not look through all that code. Maybe just post the parts you need help with. There is also a nice tutorial on the site about paginations. Take a look http://www.phpfreaks.com/tutorial/basic-pagination
-
use the <h1> through <h6> tags. Use CSS to get them to look how you want.
-
Thank you sir. Exactly what I was looking for!
-
Try something like this. <table border="1" bordercolor="red"> <tr> <td> <ol> <li><?php echo stripslashes(str_replace('. ', '.<br />', $product_info['products_description'])); ?></li> </ol> </td> </tr> </table>
-
Thanks for the long in-depth post! I ended up doing something very similar to what you described. I checked multiple times to make sure that I was not overwriting $sqlmaps and I was not. I did find a solution, but I wanted to look into it some more so I created a different script and did this. error_reporting(E_ALL); $link = mysql_connect('localhost', 'root', ''); $selectdb = mysql_select_db('replay', $link); $sqlmaps = mysql_query('SELECT * FROM maps'); while ($row = mysql_fetch_array($sqlmaps)) { echo $row['name']; echo '<br />'; } echo '<br />'; while ($row2 = mysql_fetch_array($sqlmaps)) { echo $row2['name']; echo '<br />'; } That is the code of the entire page and it only displays the set of data once. It also throws no errors. I'm completely baffled. I'm going to bed hopefully someone can explain this to me.
-
You could always use the HTML <ol> and <li> tags
-
$string = implode(',' , $a)
-
I do a query and then do a while loop to go threw it, but later down the page I need to loop threw that data again, but nothing is there. Example while ($row = mysql_fetch_array($sqlmaps)) { //some code } //some code while ($row = mysql_fetch_array($sqlmaps)) { //it dose not work here now } Do need to do that exact same query 2 times to get the data?
-
Oh right on. Thank you so much works like a charm.
-
$value is a string. I want to put that string in an array. Anyone have a good tutorial about building arrays in a loop? I've been looking, but cant really find what I'm looking for.
-
the name of the person in playerName1 which is a array
-
I'm trying to build an array in a foreach loop, but when I got to echo the results it only displays the first character of the string, but if I do a print_r on the array it show the data fine. $msgColor1 = array(); foreach ($playerName1 as $value) { $msgColor1['name'] .= $value[$i]; $i = $i + 1; } print_r show the data but when i do foreach ($msgColor1 as $test) { echo $test['name']; } Only shows the first character in the string
-
Year <select name="year_select"> <?php for( $i=1950; $i<=2100; $i++ ) { if ($i == $value) { echo "<option value=\"{$i}\" class=\"year\" selected>{$i}</option>"; }else{ echo "<option value=\"{$i}\" class=\"year\">{$i}</option>"; } ?> That should do the trick
-
PHP and SQL. Variables are not passing to Database.
Vitamin replied to aleister1987's topic in PHP Coding Help
Because I'm kind of interested in this topic. What is the logical way to send these values to the second page?