premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
[SOLVED] is this kind of an elseif statement ok
premiso replied to maztrin's topic in PHP Coding Help
Most likely, if it does not work, then no. The get is not getting the id. <?php $t = isset($_GET['topic'])?(int)$_GET['topic']:null; if (isset($t) { echo "{$t} was passed in, yay!"; }else { echo "Get data was not appened to the url like http://yoursite.com/script.php?t=2"; } ?> Give that a try and see what happens. -
[SOLVED] how to display the results of a query on two columns
premiso replied to sillysillysilly's topic in PHP Coding Help
Your never incrementing $i, so it is always 0. Also the 'type' column will never get displayed because you only have one output. There is really no need for the $i echo $dateavail[0] . "<br />"; echo $dateavail[1] . "<br /><br />"; Should display the data. -
system would allow you to access your system's zip functions and allow you to use the command line for it.
-
T_FUNCTION and why it is required in a .inc file
premiso replied to omescroll's topic in PHP Coding Help
You should not save files as just ".inc". You should save them as ".inc.php" for security reasons. As far as why, show the code and maybe we can help. -
Send the filesize with the header. It should tell the browser how long to stay open.
-
echo an image from a directory on my hosting server
premiso replied to Reaper0167's topic in PHP Coding Help
FYI. echo '<img src="$newname">'; Will not work. The $newname is taken literally in single quotes. echo '<img src="' . $newname . '">'; Would work. -
adding or change img width value dynamically
premiso replied to scvinodkumar's topic in PHP Coding Help
With the image tag: <?php $string = '<p>Also from the wonderful Tank Theory line is this nice Comrade t-shirt. She’s not all that innocent, not that she really looks it, but if you inspect the shirt closer you’ll see she is hiding something on the back. The shirt is now available in red with black wterbased print, and gold foil accents.</p> <p><a title="Tank Theory Comrade" href="http://www.tanktheory.com/store/standard-t-shirts/product/comrade/" target="_blank"><img class="alignnone size-full wp-image-2642" title="m_509_tank_theory_red" src="http://www.birdfight.com/blogfiles/wp-content/uploads/2009/02/m_509_tank_theory_red.jpg" alt="m_509_tank_theory_red" height="400" width="399"></a></p>'; $string = '<p>testing this other image <img src="blahblah.jpg" height="50">'; if (stristr($string, "<img") !== false) { if (preg_match('~<img.*width="(.*)".+?>~is', $string) > 0) { $string = preg_replace("~<img(.*)width=\"(.*)\"(.+?)>~is", "<img$1width=\"500\"$3>", $string); }else { $string = preg_replace("~<img(.+?)>~is", "<img $1 width=\"500\">", $string); } } echo htmlentities($string); ?> Tested for both (commented out the lower one to test to upper). It worked as expected. As far as if there is a better way to do this, no clue, probably since I am still new to regex. I am working on a better way to do it -
[SOLVED] Function Won't Update Info On Same Page As Info Added
premiso replied to CloudSex13's topic in PHP Coding Help
Can you store a function as a variable? I.e. $variable = add(); AS long as the function returns something. <?php function myFunc() { return "Test"; } $val = myFunc(); echo $val; // echos "Test" ?> -
[SOLVED] Function Won't Update Info On Same Page As Info Added
premiso replied to CloudSex13's topic in PHP Coding Help
Instead of echoing out, why not store the output in a variable then return that variable and echo that out where you want it to go in the script? -
The database is going to be quicker and more efficient than the xml and much more easier/versatile. I would stick to that. To answer your question, stristr.
-
[SOLVED] Function Won't Update Info On Same Page As Info Added
premiso replied to CloudSex13's topic in PHP Coding Help
The function call is what I meant. And no a function being defined is just that. It is a set of responses that when called it processes it. The function declaration could be at the end of the page but what matters is where you call the function, as Mad was kind to show you with an example. function -
No, it coincides with the name, how he had it is correct.
-
[SOLVED] Function Won't Update Info On Same Page As Info Added
premiso replied to CloudSex13's topic in PHP Coding Help
Nope, and looking at insert into I guess you can do it the way you had it, weird. The reason it requires another page refresh is because you call the function "add" after the data processing has been done. Move that portion above the data fetching portion and it should work. -
Your mysql connection gets started below 2 of the delete queries. Move that above them and it should work.
-
Either use Session to store/repopulate the data or use GET. That is you want it done automatically. If you would rather have a user push a "Post More" button you add the post data to a form in hidden input fields and make that action go to the next posting.
-
[SOLVED] Function Won't Update Info On Same Page As Info Added
premiso replied to CloudSex13's topic in PHP Coding Help
Your query is bad. mysql_query("INSERT INTO Things SET ThingID='', Thing='$addthing', Amount='$addamount' WHERE AccountID='".$AccountID."'"); Should be mysql_query("INSERT INTO Things (ThingID, Thing, Amount, AccountID) VALUES ('', '$addthing', '$addamount', '".$AccountID."'"); Or you really meant to update it: mysql_query("UPDATE Things SET ThingID='', Thing='$addthing', Amount='$addamount' WHERE AccountID='".$AccountID."'"); -
[SOLVED] tracking visits to html pages with php
premiso replied to scarhand's topic in PHP Coding Help
Create an image script that runs what you need for tracking, then displays a transparent png or gif image. Include this on each page you want to track and viola, you have tracking. -
eregi is being depreciated. Better to use preg_match What is the goal of the script. Please provide what is being input and what you expect the output. Also what are possible values of $post_eregi ? $the_e = preg_match("~(\*נעול\*)~i", $post_eregi); Give that a try and see if it works for you. Edit, it converted that text to the ascii, replace that with everything between the *'s
-
[SOLVED] php form keeps resubmitting on refresh, how to fix
premiso replied to Porko's topic in PHP Coding Help
Aside from what Mad posted. Another way is to do a header redirect after the processing is done and send them to a thank you page (or the same page with something set so it just thanks them.) Doing the header redirect will wipe out all post data. -
Single quotes interpret the $ literally. $var = $content_data[$this->row]; They are not needed for a variable, so remove them and it should work like you expect.
-
Change the input field type to be type="password" and it will hide it. This does not encrypt it, however. You have to do that on your end in the php code however you want to do it. Whether it is encrypting it or hashing it with md5.
-
Create a page profile.php where it accesses a get parameter (user). So someone can call the page profile.php?user=bob and it will show bob's profile. On the page you do a check make sure it is valid data, query the database for the username bob. If he is found display is information, if not then show a "user not found" message. Yes, during signup process you would put his information in the database so you can access it later. The profile script is simply reading from the table in the db, and should not really be doing anything else.
-
That method has to be defined in your class. It is not: <?php class myClass { public function __construct() { $this->value = "test"; } public function __toString() { return $this->value; } } $class = new myClass(); echo $class->__toString(); // echos "test"; ?>