values not getting stored in the database - php

I have a image slideshow each image sliding after 4 seconds and a message is displayed at end of each slide. I could record the message when button is clicked but couldn't record the message at the end of each slide if button is not clicked.
Here is my code:
and I also want to display random images without repetition. Can anyone help me with this?
Thank you,

Try to add second parameter to mysql_fetch_array eg:
mysql_fetch_array($result, MYSQL_ASSOC)
or use mysql_fetch_assoc instead.

This is just a general answer, but hopefully it can help you a bit. In your question, you posted a whole bunch of code for us to deduce the problem. This is both a good thing and a bad thing. It is good because you have posted enough information for us to be able to help you and figure out what is going on.
However, it is also bad, not in the sense that you are doing something bad, but in the sense that it is highlighting where you are having your problem solving this issue. Again generalizing, problems with code are usually simple in nature. They become complex because of the complexity surrounding and obscuring them. In order to help you with this problem, and in order to help yourself (both in general and in this case), you should start by narrowing down the scope of where the problem occurs.
For instance, in your question, you say you have an issue recording a message. However then you say "I could record the message when button is clicked. " So you have introduced a new variable into your question without telling us about the button. So we aren't sure anymore if you are having an issue with the button, or with recording the message.
So what I am saying is, narrow down your problem, and nail it down. You should be able to make a solid statement like this: There is a button, that when clicked should record a message. However, when my application moves a slide from one to the next, the button no longer works. In order to do this, you will need to define exactly what behavior you are trying to make happen. Even if this isn't a formal project, you should make a use case (even in notepad is fine) where you exactly describe what functionality you are trying to make happen (implement). You will then be able to exactly describe how your code is not doing what you said you want it to do.

Related

Need advice about making a forum with php

I am trying to create a forum on my page. I need some advice. I have MySQL database and I am able to to work with it. Yet as far as I can make is playing with POST. I mean on click submit a $_POST['submit']) becomes set and so on. Then connect to database, get info and display.This way of making a forum is bad, because it all happens on a single page. As far as I seen any other forum when entering one and so on has it's unique Uri (what comes after domain.com/) so you can simply send someone full url and they are in that thread (unlike if you play with $_POST['submit']).
Sorry if my question is not accurate and I am not asking to write me code. I just need someone to direct me to the right place and any advice would be helpful. Thanks !
Your question is difficult to understand, but I think you are confused about how data and pages are dynamic using GET/POST.
The URLS with different IDs are like an illusion. Really, its the same page, however the page is dynamically taking that ID from the URL, and using it to output certain data.
For example, say we habe the URL: www.example.com/show_thread.php?thread=3
The php would look like
if(isset($_GET['thread'])){
$data = $db>query("SELECT thread_title,thread_text FROM threads WHERE thread_id = $_GET['thread']");
print($data);
}
*Warning: do not use this exact code, it is an example, not secure, etc
Then the database would look like
thread_id thread_title thread_text
1 kngwihywoihwy kngwihywoihwykngwihywoihwy
2 vyfngoieyoiehyon ieonuwrtoi hunwrmt jirwyji
3 nuoaiefguneoihn eoithneiotheo
and the page would show
nuoaiefguneoihn eoithneiotheo
POSTing data is for sending it to the server, and doing something with it. Just like GET. However, GET is helpful for passing things around as they are accessible in links. Like this example.

Phprunner the event code on changin row background color

I know there is a forum for this issue but seems like WOT has warned something. Don't know exactly what is happening to the site but hope some guys out there can help me since no one answered my question there.
Main Problem:
Here is my code on List Page: After record processed event
if (strtoupper($data["Availability"]) =="SOLD"){
$row["rowstyle"]='style="background:red; color:white"';
}
I even tried to print the value of "Availability" inside the condition and it prints exactly as SOLD but seems like nothing happened.
NOTE This is important:
I can see that the row background changes when refreshed or during few seconds of loading (SEEMS WORKING!) but after that the color gets back to its original settings.
Hope anyone can tell me that this is a bug or am I really missing something.
References: PhpRunner Manual and http://xlinesoft.com/blog/2011/01/03/tutorial_conditional_formatting/
Found the answer. thanks
Dont check 'Resizable table columns' on Miscellaneous page under 'Table Specific Settings'. Not a great answer though, but solves my issue.

From PHP to jQuery?

So I've been struggling with finding a simple and efficient solution for the following problem. The solution I have now works, but since I'm working on this for the sake of learning ...
So, the case:
I have a PHP page which gets loads of persons from a DB, then sorts them and finally puts all persons
in a html list. What I'm after is a elegant solution to edit these persons by clicking on them from the list. I've found a jQuery pop-up solution that looks brilliant, but not so easy to use for beginners.
Since there are several persons I need to produce a different pop-up window depending
on which person is clicked. The problem is that the jQuery pop-up is based on the html being pre made, which is obviously hard since I don't know which person the user will click.
The best I've come up with so far is sending a GET -variable to the page with the person list, which then checks if there is a valid variable from GET and produces the HTML for the clicked person based on the id/variable. The problem with this is that I have to essentially run the same query twice; once to get all persons and once to get the clicked person. It isn't a big problem, it's more that since I'm new with jQuery I'm wondering if there is a simpler/better solution. I'm not really sure what jQuery can and can't do.
Thanks for any replies.
I'd start by asking why you don't ask the database to sort/ORDER the values before sending them back to your PHP page? It's well-suited for that sort of thing.
You could know which person was clicked if you added the database id to each element and passed that around. Have jQuery add it to the DOM element for each row in the HTML table.
kinda the standard way would be to pass the persons as JSON, and use the jquery templating system to build the forms. Of course this could be a bit daunting to a beginner, but its not that hard.

Best way to create an auto-rotating "news" feed on a website?

my client is asking for an auto-rotating news feed type thing on their site. The content will not change, but it will automatically move from item to the next. It will also allow the user to mouse over previous items and hold them in place.
This is best shown by the type of thing you find on Yahoo's homepage:
The four news items will auto-rotate, but when a user puts their mouse over one (as shown), it will stop rotating and just show that one, until they move it away (then it will continue auto-rotating).
I imagine I can do this with a lot of $('item1').fade and $('item2').appear type malarky using Prototype and Scriptaculous, but I was wondering if there was a better way, or an existing bit of code I could use (it seems like quite a common thing, these days).
Thanks for any tips or assistance!
Took a little googling to find one but this looks exactly like your provided example:
http://www.agilecarousel.com/flavor_2.htm
Here are some other, simpler carousels that have been out in the wild for a little longer:
http://sorgalla.com/projects/jcarousel/
http://www.thomaslanciaux.pro/jquery/jquery_carousel.htm
http://www.baijs.nl/tinycarousel/
Hope this helps and good luck!

Tracking Quiz Results with URL, No Database Allowed!

I need to create a 10 page quiz for a mobile browser. It is only a mobile webpage, so no considerations need to be taken for other browsers.
Here's the problem I'm having: I can't use JavaScript, because not every mobile browser supports it. I'm not very skilled in other languages, but I thought perhaps something could be done in PHP as it is server-side.
If my first URL is domain and I enter the correct quiz answer, the URL to the next page could be domain/?p=1. The URL doesn't need to do anything but hold a count of the number of correct results.
As for the actual code, I was thinking it could be included in the HTML itself, as I'm not very concerned about people viewing the source on their mobile phones.
Is it possible to write a line of code that increments the 'p=' attribute in the URL by one when clicked and only attach it to the correct answers?
Here's an image of what I mean: http://i.imgur.com/HbJ5U.jpg
And, what's to stop me from manually incrementing the "correct answer" counter in my address bar?
Do you not want to use a database because you don't have one available to you in your hosting, or because you don't know how?
I'm not a fan of the idea, but you can get the number of "correct answers" with the following code.
<?php
/* Gets current correct answer Count */
$answer_count = $_GET["p"];
/* checks to see if the submitted answer is the same as the correct answer */
if ($_POST["submitted-answer"] == "correct-answer") {
$answer_count++;
}
?>
Now, you just add the modified answer count to the link to the next question.
Next Question
If this is "just for fun" I don't see why you couldn't do it like this. It's definitely a simple way to solve the problem.
The standard way to do this is to store things in hidden form variables. Of course, if there is anything riding on this, that's a terrible way to do it, because it's really easy for the end user to put his own values in those hidden form values.
Aren't file-based sessions the obvious answer here?

Categories