Hi, I'm working on a page that GETs a value that is passed in the URL. This variable echos correctly up until I try echoing it inside an if statment where it needs to be. The variable is called $siteid. Inside my if statement I have a query that runs WHERE id='$siteid' Inside this if statement it won't echo out. It is the weirdest thing. I tried to hardcode the siteid as 95, to test it, and the query updated my database as it should. However, leaving it as the variable it will not work. Any help solving this mystery that I've been banging my head over fo
Articles similar to Variable Mysteriously Stops Echoing:
Initializing Variable Within a Loop
Suppose I have this loop statement:
Code:
int x = 0;
while (x < 5){
int y = x++;
}
Does this mean the variable y is initialize every time we go through the loop? Or does it mean the variable y is not pop off the stack until the loop end? To put it simply, is it faster to declare y inside or outside of the loop, given that I won't use y outside of the loop?Setting variable inside parenthesis?
Hello,
I have a snippet of a page I'm working on that, if the if statement is selected, it would run this code:
PHP Code:
$beastdata['xpgiven'] = $xp;
$beastdata['goldgive'] = $penny;
$userid = $_SESSION['user'];
$query = "UPDATE `user` SET `xp`=(`xp`+'$xp') WHERE `username` = '$userid' LIMIT 1";
$qresult = mysql_query($query) or die('Query: ' . $query . '<br />Failed with: ' . mysql_error());
Stripping tags from PHP variable for PDF generation
Hi, I'm using a PDF generator (FPDF) to output a field from a mySQL db, which is represented by a PHP variable. This also appears on the page from which the PDF is generated, and works fine as the HTML tags which are inside the data are interpreted properly by the browser.
Obviously the variable gets interpreted literally by the PDF generator so what's happening is that <p> and </p> and other markup (and also backslahes to escape apostrophes) is appearing in the PDF.
php variable in MYSQL query
Good day to you all,
I'm working on a script which would read a url var and sort mysql table by the variable, but I always get the errore that :
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in DB_API/sort_column.php on line 13
Can somebody help me fix my problem. I think it's the variable that is not use right in the MYSQL query (
PHP Code:
$result = mysql_query("SELECT * FROM NHL_GBG_PLAYERS ORDER BY {$col}");
)
Here is my code :
PHP Code:
<?php
$con = mysql_connect("localhost","sports","sports");
if (!$con)
{
die('Could not connect: ' . mysql_error());
Help - passing variable inside of src
I am familiar with php, but not so much with JavaScript.
I found a Google Gadget that basically gets driving directions that I want to use on my web site. Basically there are two text boxes: one for starting point, and one for destination. I want the destination box to be filled in based on a php variable that controls the location.
In a nut shell: I need to use a php variable $locgoomaps and pass it to the javascript and use it within the SRC tag. But, being very new to javascript, I am finding this to be quite frustrating.
1) Currently this is being placed in the body of my page.
What I have been able to accomplish so far is this:
Code:
<SCRIPT LANGUAGE="javascript"><!--
Setx Tool
What's Up Homeboys?
But seriously, I'm trying to take a word from a text file and put it into a variable so I can call it later on. After alot of googling I came across a resource kit 2000 tool called 'Setx' However there isn't a lot of syntax help. Can anyone see what's going wrong here?
Code:
SETX Var -f txt.txt -a 1,2
I've tried then echoing %Var% but it just echos ' %Var% '
Thanks Bye!MySQLi prepared statements for speed?
Leaving aside the benefit for security, does mysqli prepared statements have any performance benefit?
As I understand it, the prepare stores the query in parsed form at the database server, and when doing execute, then only the data for any values are passed from script to database.
Direct benefit would be that the database only need to parse SQL once, and that less bytes (only the values) are sent on each query.
However, is this not only a benefit if the query is executed repeatedly inside the script, or does MySQL store the prepared statement between requests? If so, for how long?
