Jessica
Staff Alumni-
Posts
8,968 -
Joined
-
Last visited
-
Days Won
41
Everything posted by Jessica
-
If all 20 prices are different you'll need to use a foreach. Are you having an actual problem or is this just theoretical?
-
We'd need to see more of your code and database structure to help. A foreach would work but you could probably do it much easier with one SQL statement to update all items in the users shop with the price.
-
First of all it's PHP, not Php. Secondly, Java can be used for websites, but it sounds like you are thinking about a java program to run on client-side, not a website. PHP can be used in conjunction with MySQL, HTML and CSS as well as Javascript to create a lot of different "effects" and different ways to process information. I think you need to do more research - PHP runs server side - it's processed before any text is output. To make a "table invisible" on a website would be css/html not php. Flash overtop of HTML - still html, not PHP. You can use PHP to generate the HTML but you have to know how to do it in HTML already. PHP and HTML are different things with different uses. PHP does not display "tables", tables are HTML. If you mean tables in your database, that is MySQL. You can use PHP to work with MySQL and display the information on a page, yes. I think you're nowhere near building an e-commerce site. If you need one soon, either use ZenCart or hire a developer and be prepared to pay.
-
Taking info from a form, saving it in a DB and writing it to a .css
Jessica replied to penguin0's topic in PHP Coding Help
I've only really had trouble with browsers caching image files which are dynamically created, especially Firefox. I have my css generated using a .php file and I never see it cache. Could be just me. -
You need to make variables for each one so that you can "sanitize" the user input on each variable. If it's something that is not POSTed but is in your code like a constant, you don't have to clean it. It looks like all of yours are user input, so you need to make sure they are what you expect, to prevent errors and "hacking". So if $built or $style can ONLY ever be a number, you can skip the mysql_real_escape_string and just use intval(). If it's a string, you need to use escape_string to prevent errors and injection. (If you have magic_quotes_GPC turned off which you really should IMHO.)
-
[SOLVED] Will this work? Wrapped function for numrows.
Jessica replied to matthewhaworth's topic in PHP Coding Help
Heh I never even paid that much attention - dbo is right, you are sort of re-inventing the wheel. -
Question about replacing mysql_escape_string
Jessica replied to fingerprn's topic in PHP Coding Help
I wondered the same thing and I think it's because of the connection thing. People do silly things -
Google "SQL Injection". Also, in the future, when you don't know what a function does go to php.net/function so http://php.net/mysql_real_escape_string will tell you what it does and how to use it. Googling SQL injection will give you more info on why to use it and other functions.
-
I think the info in the file is wrong...since there is an error. Just contact your host.
-
Yeah you need to use the variable like $built - as long as you are cleaning it properly by using things like mysql_real_escape_string() If you have an auto-incrementing column you just leave it out of both parts, the columns list and the values list.
-
[SOLVED] Will this work? Wrapped function for numrows.
Jessica replied to matthewhaworth's topic in PHP Coding Help
It would have been faster I bet to have tried it out by now Or at least switched it to an if-else. According to the manual http://us3.php.net/ternary I think it will work. -
Well most of us are probably using the quick-reply and don't bother for ONE LINE OF CODE.
-
[SOLVED] Will this work? Wrapped function for numrows.
Jessica replied to matthewhaworth's topic in PHP Coding Help
I said I didn't THINK it was right. You're way too concerned with your speed in situations when it is not important. Faster code does not give you a larger organ you know. -
You have to do it like this: INSERT INTO tables(fields here) VALUES(values here) and leave the first one out. So: INSERT INTO houses('built') VALUES(1234) will insert a row with the auto-id and the built column filled in. Make sense?
-
[SOLVED] Will this work? Wrapped function for numrows.
Jessica replied to matthewhaworth's topic in PHP Coding Help
I don't know, it just doesn't look right...but I never use ternary because it never looks right. It's too confusing. It's like using ASP style tags. -
[SOLVED] Will this work? Wrapped function for numrows.
Jessica replied to matthewhaworth's topic in PHP Coding Help
Oh..and: You want us to do the hard part of thinking it out for you, so you don't have to actually use the code you've written? -
[SOLVED] Will this work? Wrapped function for numrows.
Jessica replied to matthewhaworth's topic in PHP Coding Help
Look up the ternary operator...I don't think you're using it right. Just use an if(){}else{}... it reads better. -
Question about replacing mysql_escape_string
Jessica replied to fingerprn's topic in PHP Coding Help
I don't think he's asking how to, I think he's asking if it will cause any problems with the code. -
Taking info from a form, saving it in a DB and writing it to a .css
Jessica replied to penguin0's topic in PHP Coding Help
Yes, PHP can generate a CSS file using header(), or can just write to the file. -
Question about replacing mysql_escape_string
Jessica replied to fingerprn's topic in PHP Coding Help
As the manual says: This function is identical to mysql_real_escape_string() except that mysql_real_escape_string() takes a connection handler and escapes the string according to the current character set. mysql_escape_string() does not take a connection argument and does not respect the current charset setting. The only potential problem I see is if in the current code mysql_escape_string() is called when there is no connection to the DB, it will fail. If that is not a possible problem, switch them all over! -
Best time to learn, eh.
-
Your reply made no sense. If your no was to my first comment, yes, it should. If it was to my question, then add it to your page. If your host allows PHP, then you can have dynamic images generated by PHP. The code you posted does not show anything about the image anyway.
-
Why would I waste time writing the same code over and over when I can have a function do it once?
-
This should be in third party scripts. But does your form page have a session_start()? A captcha like that will probably need it.
-
Just to add to what Andy said, I usually use date("Y") and then date("Y")-100 (or whatever) for the whole year range. That way it always adjusts for the new year, and you won't end up with 1900-2020 in a few years. Since you've made a drop down menu function, you might consider working on other form functions. I have a class I use for any form, which handles error checking, etc. So if I want an input field I just use it. function finput($label, $id, $value=""){ print '<label for="'.$id.'">'.$label.': </label><input type="text" id="'.$id.'" name="'.$id.'" value="'.$value.'" />'; } Etc. You can also add in stuff like if the field is required and save it to an array, so your error checking is faster/automated.