-
Posts
3,145 -
Joined
-
Last visited
-
Days Won
37
Everything posted by cyberRobot
-
That depends on what the OP (sithsta4) is trying to do. The "shop" variable being in a hidden form field won't work if the OP wants a visitor to click on a link that's not connected to the form, for example. In that case, a GET (or SESSION) variable may be a better choice.
-
Perhaps you're already aware of this, but $_GET and $_POST variables can be tampered with by the user. So keep in mind that you'll need to validate/sanitize the value. If your "shop" variable is supposed to be a number, for example, you can use ctype_digit() to make sure it is. At a minimum, you should use something like htmlentities() before the value is used in things like hidden form fields and anchor tags.
-
It might help if you provide more information on what you're trying to do. If you're looking to maintain a variable throughout many pages of a website, you could look into SESSION variables: http://www.php.net/manual/en/session.examples.basic.php
-
Will all the questions be displayed at once? Or will the user answer one question, reload the page, answer another question, reload the page, etc.? If all the questions will be displayed at the same time, you could build a single HTML form which passes all the responses to PHP at the end. If the questions will be asked one at a time, you could display a form with the first question. The form would submit to a PHP script for processing. The script would display the next question while passing the previous responsive using hidden form variables or maybe a PHP Session variable. Then just repeat until all the questions have been answered.
-
I'm probably missing something, but the foreach should do what you want without the "[*]" part. foreach ($_SESSION['cart']['content'] as $content) { echo $content['productname']; } This should display the product name for both "foo" and "bar".
-
Have you tried using mysql_error() to see if MySQL is throwing errors? http://www.php.net/manual/en/function.mysql-error.php It's difficult to tell since you're using * to select all columns, but do each of the tables contain the same number of columns? Note that you'll be better off to list out the columns. That way you can make sure the result set contains what you expect. Keep in mind the following quote from the manual:
-
Have you looked into using UNION? http://dev.mysql.com/doc/refman/5.0/en/union.html
-
How to combine these two outputs as one
cyberRobot replied to chauhanRohit's topic in PHP Coding Help
Is there a connection between the two database tables? For example, are the author IDs referenced in the books table? If so, you could look into merging the queries with a LEFT JOIN: http://www.tizag.com/mysqlTutorial/mysqlleftjoin.php -
Help with getting PDF search results to appear as Hyperlinks
cyberRobot replied to mike2's topic in PHP Coding Help
Also note that I don't understand why this <a href="<?php echo $r->swishdocpath; ?>"> outputs this <a href="1./ITA000030409.2013.3.00.L.09.30.PDF"> And this <?php echo $r->swishdocpath; ?> ouputs this ./ITA000030409.2013.3.00.L.09.30.PDF I don't see where that "1" comes from. It sounds like your links are working now, so maybe it's not an issue. -
Help with getting PDF search results to appear as Hyperlinks
cyberRobot replied to mike2's topic in PHP Coding Help
That's up to you. I would imagine that swishtitle is supposed to display the title of the document which would be useful to some. If you want to use it, you'll need to go back to the documentation and/or do some research to see what's going on. Note that I haven't used the SWISH object before, so I'm not sure why it doesn't work. -
This seems to work: if($i % 4 == 1) {
-
If you're looking to split data in groups of 4, you could use array_chunk(): http://www.php.net/manual/en/function.array-chunk.php
-
Help with getting PDF search results to appear as Hyperlinks
cyberRobot replied to mike2's topic in PHP Coding Help
Try adding the anchor tag around something you can click. For example, you could try something like this: <a href="<?php echo $r->swishdocpath; ?>"> <?php echo $r->swishdocpath; ?> </a> -
When the refresh button is clicked, the browser resubmits the form. You could look into preventing this by using the header() function to redirect to the confirmation page. http://www.php.net/manual/en/function.header.php
-
Note that the following code is untested, but you could try the following: <?php if($link->getAttribute('href')) { if(!$link->hasAttribute('id') || $link->getAttribute('id')!='aTest') { $url = str_replace(" ", "%20", $link->getAttribute('href')); $url = str_replace("rtmp://", "", $link->getAttribute('href')); } } ?>
-
You could add an if condition which checks for links with the "id" attribute...or an "id" attribute with a specific value ("aTest").
-
Is $limit defined within the script? If it's not, you should get an error if you call mysql_error() as SocialCloud suggested: $a = mysql_query("select * from twitter_access_tokens ORDER BY RAND() DESC LIMIT ".$limit) or die(mysql_error());
-
It looks like the content is too tall for the window. The scroll bar doesn't appear because you're using "position:fixed;" which removes your divs from the normal flow of the page. For what it's worth, I was able to get the last div to fit on the page by changing the height to 60%.
-
Alternatively, you could use array_chunk() to break apart the columns. http://www.cyberscorpion.com/2013-08/build-html-tables-dynamically-with-php-part-2-simplify-with-array_chunk/
-
Is there any documentation available from Virtual Merchant which describes how the information should be sent?
-
Ah yes, thanks for the correction. Now how do I rewire my brain.
-
It sounds like the CSS styles for "selected" weren't taking precedence. How did you add the CSS code? Perhaps the following will help: http://css-tricks.com/specifics-on-css-specificity/
-
Finding a biggest number in mysql table
cyberRobot replied to saynotojava's topic in PHP Coding Help
Have you tried using MySQL's MAX() function? https://dev.mysql.com/doc/refman/5.0/en/example-maximum-column.html -
Just to clarify, the real reason to switch to MySQLi or PDO is that the mysql_* functions have been depreciated. More information can be found here: http://www.php.net/manual/en/mysqlinfo.api.choosing.php If you're not quite ready to make the switch, you can prevent SQL injections with mysql_real_escape_string(). http://www.php.net/mysql_real_escape_string
-
Need help with empty field error message
cyberRobot replied to outdoorxtreme's topic in PHP Coding Help
Before running the code to process the form, you could test to see of the form has been submitted. For example, you could do something like this: if(isset($_POST['Submit'])) { //code to process form here } You could just leave the action attribute blank. echo"<form id=\"sms\" name=\"sms\" method=\"post\" action=''>