What is the program you are using? What type of SQL server are you using? Have you learned programming in PHP?
Aia commented: *nods* +13
Salem commented: Quite so +27
What is the program you are using? What type of SQL server are you using? Have you learned programming in PHP?
// Get file name from URL and remove any bad filename chars.
$url_parts = explode('/', $url);
$num = count($url_parts)-1;
$file_name = $url_parts[$num];
$badchararray = array(" ", "'", "\"", "$", "&", "%", "-", "#", "^", "*", "(", ")", "~", "@", "/", "?", "=");
$file_name = str_replace($badchararray, "", $file_name);
$file_name = stripslashes(strtolower($file_name));
if(strlen($file_name) > 40)
print("File name is too long please rename your file shorter and then upload again.\n");
else if ($append_file_name == true) {
$save_name = $id . '_' . $file_name;
}else {
$save_name = $file_name;
}
If you have to use array notation, also consider using a static variable instead of a parameter:
void enter(int *p_arr)
{
static int insert = 0;
printf("\nplease enter the number:");
scanf("%d", &insert);
p_arr[i++]=insert;
}
Another solution (I know, you see this one all the time): don't use scanf or it's partners. If you use low level input functions and do the converting yourself, you have much more control over what you can do.
When printing the form, just put the PHP variable in the "value" attribute of the input field.
http://www.daniweb.com/forums/announcement118-2.html
If people would READ once in a while, we would all be spared a whole lot of trouble.
taichou, I provided links with the hope that you would read them and maybe learn from them.
Sorry, I was talking about the lowest subdivision of data programmers can work with: the byte. Yes, addresses certainly require more than 8 bits.
I still don't know where your 'door' variable is coming from, and some specific errors other than "doesn't work" would be much more helpful. Are they compiler errors or does the code just not produce the right output?
Does your teacher explain anything else about making the graph? You can make a table of sorts in a console screen.
Can you include some variable declarations? Otherwise I can't understand how
door[door]
even compiles.
If you really want to, you could write C libraries that mimic java code, as well as many other languages. It would work best in C++ however, which provides a lot of functionality for class-based designs. Most important here, i would think, is operator overloading.
What on earth do you need a binary counter for in a tic tac toe game? Computers store everything in 8-bit binary. How you refer to the number doesn't make a difference, other than maybe speed.
grep stands for global / regular expression / print. First try a search on a way of performing regular expressions in C. Then find a good tutorial on how those work.
I think what you want to do is just return the one or zero rather than a struct. The operation can be passed as a pointer to a char (in the parameters). a, b, and c don't need to be pointers.
Instead of this:
for(b = 1, m = len; m > k; m--)
{
// 1 2 4 8 16 32 64 128 ... place-values, reversed here
b *= 2;
}
// sum it up
sum = sum + n * b;
Include <math.h>
and replace your the previously mentioned code with this:
sum += n * (int)pow(2, k);
I'm really not sure anymore. Now I just declare all my functions before I define any of them. It works and I can't see it being a poor solution.
Sorry, my terminology is a little off. I meant just the function header, with no body or code.
Oh man, I just realized a pretty major mistake I made in a previous explanation.
Just put all the function definitions in one header file and have all the other headers include it.
I meant delcarations. Only the function headers would be in this file.
I didn't fix this specific problem, but due to another fix I only needed to pass one parameter through CreateThread. This made it easy enough to just have the window creation and message loop in one thread.
I didn't quite understand that. I get the idea of using a common header for system includes. But the rest I wasn't sure of. Am I right in thinking this: include all formal function declarations first, then all their definitions?
Sorry for all the stupid reposts, but you can only edit for so long. Anyway, I refined my previous idea. Just put all the function definitions in one header file and have all the other headers include it. That way every function knows about every other function.
I had a thought, what if you just declared the function you need to reference in the top of the file that uses it? If file header1.h needs function doSomething() which is defined in another header, put
void doSomething()
in the top of header1.h
Check out GMP (Gnu MultiPrecision). It allows you to work with extremely large numbers and has wrappers for c++.
There's a good reason why you're not supposed to feed the bears. If you give them something for free, they'll expect that all the time and won't figure out how to feed themselves. It would seem that people can be the same way...
Nope, sorry. The GL stands for Graphics Layer, so they didn't include input, sounds, or any of that other good stuff. I'm sure there's other good api's for input, as microsoft can be a b**** to work with. In that case, google is your friend :P
My application creates a window in the main thread, but I want the message loop in a separate thread. Is there any way to catch the messages from that window while an another thread? I tried giving GetMessage that window's handle, it didn't work. I could just create the window in the separate thread as well, but that would mean dealing with the single void pointer i'm allowed to pass through CreateThread which I would prefer to avoid.
I started experimenting with all sorts of bizarre extern statements and separate .c files but I realized it would be a lot easier to require the client (main) to call the subsequent functions, rather than have them call each other. It will require more parameters but it seems to be much better style anyway.
I am having some trouble with the layout of my project. I'm using several APIs, including the WinAPI and DevIL. I had hoped to encapsulate each one in a separate header file, so that the main program would never have to know whats going on. The problem is, some functions have to refer to each other in different files. Is there any way I can let them do this and still keep the encapsulation?
You will likely have to use DirectInput. It provides a *sort of* simple api for dealing with any kind of input device imaginable. Sort of.
Oh wow sorry, I'm not great at javascript so I was doing my usual bizarre, roundabout way of doing things. Just use ajax!
Try this:
<script>
var time=1;
function timeHere() {
time = time + 1;
finalTime = time / 10;
}
// function mostly from w3schools.com
function sendTime(t)
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return;
}
}
}
xmlHttp.open("GET","time.php?t=" + t,true);
xmlHttp.send(null);
}
function sayTime() {
var xmlHttp;
finalTime = time / 10;
//return finalTime;
alert("Thank you for coming to my site! \n You have been here " + finalTime + " seconds!");
sendTime(finalTime);
}
</script>
A side note, isn't it wonderful how complicated Internet Explorer makes everything? :\
For more info on AJAX, try w3schools: http://w3schools.com/ajax/default.asp
Have an invisible <iframe> in your page somewhere, have sayTime() refresh the iframe to a page that will take the time as a get variable in the url. The invisible page can then store the time in a database.
Where is your application located? On a website? In that case have the users download (or just make it themselves) an internet shortcut to that page. If its an application that runs directly on their computer, create a shortcut to a batch (.bat extension) file with something like this in it:
php applicationfile.php
Check out this link for more info on using PHP from the command line.
Sorry about my incorrect usage of explode in a previous code example, its been a while since i've actually written PHP. (I've got java on the brain)
Oh dear. Do you have the option of reformatting the info file? Because this looks like a job for xml to me.
Would you care to be a little more specific? The width of what column is increasing? And why is this a problem? HTML tables will fit to the largest width by default.
Thanks for resurrecting an old thread that has absolutely nothing to do with your problem just to ask for someone to do your bloody homework for you. Thanks for wasting people's time.
Sorry about that. I made a quick program to test it and you're right Selem.
Okay, here goes:
<?php
ob_start();
include_once('listtext.txt');
$listtext = ob_get_contents();
$listtext = explode($listtext);
$array = new array();
for($i = 0; $i < count($listtext) / 8; $i++) // replace 8 with the number of fields
{
$array[$i]["last_name"] = $listtext[$i * 8 + 0]; // put something to remove the comma
$array[$i]["first_name"] = $listtext[$i * 8 + 1];
$array[$i]["phone"] = $listtext[$i * 8 + 4]; // skip the "phone" and "(H)" labels
$array[$i]["birth"] = $listtext[$i * 8 + 6];
// add similar statements to get the other fields or just skip them
}
ob_end_clean();
print_r($array);
echo "<br><br>";
echo $listtext;
?>
Oh wow I completely missed the point of your code. Um you can't find out when the user left the page using PHP, not that I know of at least. I think you would have to use Jaseva's method of passing it to the next page through a form of some sort.
First off I need to correct myself. When doing pointer arithmatic (ie. *(glblclrtab + i)) c automatically accounts for the size of the elements. As for the other point, I have not tested it but try reading this link: CTutorial.html#Arrays%20and%20Pointers
Please use CODE tags. And could you post the relevant code so we don't have to wade through all of that? Try posting just where it is getting or defining the categories/subcategories and where it is adding things to a table (in a database, I assume). But without looking at code (sorry, I'm lazy) I think you could add a field for a parent category. It would refer to the id (an id field is also needed, if you haven't already made one) of another row in the table. It could be -1 if it is a top-level catergory, to distinguish from a subcategory.
If "payment.phm" isn't a typo, then its the problem. Check the filename. Otherwise, is payment.php in the same directory as paymentform.html?
Maybe you should take a look at how str_replace is used: str_replace. You have to provide something to replace 'new_ad' with. Plus, the function doesn't store the new value in the place of the source string, it returns it so you need to store that somewhere. Try:
$new_result = str_replace($find_ad, 'new ad', $new_ad);
$new_ad should be whatever you want to put in-between the ad tags. Then you can do whatever you want with $new_result.
If you want to use the $time variable somewhere else in the same page, you would be better off getting the time with PHP and then printing it, rather than using the javascript.
That massive amount of code is a huge turnoff for potential help. Can you post the relevant parts? And it would help if you could be more specific with your problem. (Not more wordy, as some people seem to think)
Try exploding with spaces. If you know how many fields there are, (with n being the number of fields) you can say every (nth) field is last name, (nth + 1) field is first name, and so on. This does assume that individual fields cannot contain spaces as part of the value. If you need some sample code, I can provide it.
Submit takes me to payment.php, which doesn't exist. What file is the code you provided supposed to be for? At any rate, this is not a PHP issue.