-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
Problem with arrays and multiple values per key
ginerjm replied to Epimetheus1980's topic in PHP Coding Help
Backing up for a bit. Your first post indicates you have a db field that contains multiple values. You might solve your problem if you simply followed the rules of a properly structure database. Normalization (look it up) means you never put multiple discrete values into one field, but rather put them into separate records of a separate table. In your case that means that this: [field1] authorA1989; authorB1978a; authorB1984; authorC1999; authorC2000a; authorC2000b; authorC2002; authorD2009 being in one field of a table would become multiple records in a separate table: [field1] authorA1989 authorB1978a authorB1984 authorC1999 authorC2000a authorC2000b authorC2002 authorD2009 where this table is linked back to the first table by some id value in the first table. You really need to understand this and implement it. -
I think what our OP doesn't connect on is that he has to modify his existing(?) pages to pass the appropriate query string in his url to feed my code. Tried to get him to show me his code, but for some reason he couldn't. And that was that.
-
You apparently didn't understand my original proposal for solving this problem. Perhaps a re-read would help but probably not. You don't have a good enough understanding of how web pages interact and how php can be used to act and react to events. Good luck.
-
You really are thick. You said "all of the code for the site is in those includes". I said show us your code. That means show us the contents of those includes. Simple, no?
-
Show us your code. What don't you understand about that?????????? Jeez!
-
You explained it perfectly. You didn't understand what I proposed to you and you don't understand how to utilize the code I gave you. I gave you something YOU could use in conjunction with your existing code but apparently you don't have any existing code.
-
I'm afraid it is you who doesn't understand. Good bye
-
This is not what you ran. YOu have to have some webpage that triggers this script. Show me that.
-
No. Your question seemed knowledgeable so I made the erroneous assumption that you could follow my example. Again - show me what you ran.
-
Show us your code that you developed from my little sample
-
Your last example could do this for you although I would think you might use something other than 'filename.html' as the parm in the url. Maybe just a code or a word that your called script can use to lookup on a table or a static list of actual filenames and THEN execute the include. Say your current web page has some kind of action that chooses the next web page to be built and loaded. The script that it triggers does this: if (isset($_GET['file']) && $_GET['file']<>'') { $file = strtolower($_GET['file']); if (array_key_exists($file,$files_ar)) $include_name = $files_ar[$file]; else die("Invalid url value"); include('header.php'); include($include_name); include('footer.php'); exit(); } else die("Missing url value") exit(); All your pages would call this one script. Each page would be responsible for passing the next page's code/name in the url when it calls this.
-
PHP shows Username and Pass don't match when I know they do...
ginerjm replied to Masonh928's topic in PHP Coding Help
Change this line: if($ROWS != 0) to something more logical. It probably works but it's silly IMHO. if ($ROWS) And then - comment out the header line and replace it with an echo confirming success and let's see what you get. -
embedding a youtube video within a concatenated string
ginerjm replied to moose-en-a-gant's topic in PHP Coding Help
Why does your output have to be "in a string"? Design your output page and then write the html code to present it that way and THEN worry about how to get the data items into it. As for showing an image of a video. Not familiar with any of this but can you actually show an image (a single frame?) from a video file? -
Hashing is not supposed to be reversible. If the password is forgotten, your ensure that the right person is asking for a reset before setting a new password. Usually you do this by sending it to the registered email address stored with the userid. It is then the user's responsibility to ensure that his email account is not accessible to anyone else.
-
You don't say what leads you to believe that it is NOT doing the inserts? I assume that you looked at the table and didn't see anything. Try adding php error checking (see my sign.) and also add error checking after each call such as your db connection, db select and query calls to be sure that they in fact were successful. Good practice.
-
It's still telling you that the MySQL handle is invalid. You need to check the results of each of the connect, db select, query calls BEFORE trying to use them to count the rows returned, to retrieve the data returned, etc. Check your syntax against what the manual tells you to use. The manual is your friend. Use it.
-
HTH! And BTW - your code was actually looping. You just couldn't tell because of your one mistake.
-
If you are serious about this, I would go buy some books and manuals so that you get the best info at all times. Using the internet and the info you will find there can be problematic when you find poor info and data and try and utilize it. Sure - there is lots of good info out there but how will YOU recognize it? How much time are you willing to waste doing the wrong things? Perhaps your question should be to ask for recs on the best print media.
- 5 replies
-
- help
- big project
-
(and 2 more)
Tagged with:
-
You can't concatenate to a variable without creating it first. So - before your loop you must initialize the vars
-
That - and you have your table/form jumbled up. One has to be completely inside the other.
-
So ? You now have an array called $devices. Each element of that array is in itself an array that contains many items. So you begin a loop on $devices which gives you one element at a time and that element is itself an array, so you begin a loop on that array to get each key & value from its items. Just like the code that you built $devices with. What do you want to do? Get Beth's state value? foreach ($devices as $device) { if ($device['name']== 'Beth') echo "Beth's state is ",$device['state']<br>"; else if ($device['name'] == 'Clint') echo "Clint's state is ",$device['state']<br>"; } Something like that? If 'name' is going to be the real key of all the data, then maybe you should assign the xml data to an element of $devices that uses the key of 'name' as the key for $devices. Then you could simply retrieve all of Beth's data by referencing $device['Beth'] in my above code, as $device['Beth']['state'];