Variable Not Passed To Mysql Query
It seems that my code as below is not passing the variable content to my WHERE clause in my MySQL query. If I do an echo on it, the value displays, but when I look at the query using echo "Query: $q"; my value is empty. Code:
View Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
Variable Passed In Through Header
We recently upgraded PHP and variables that were once passed through the URL are no longer recognized. Example: http://www.sun.com/test.php?defectID=2 Within the test.php code: <?php session_start(); $defectID = (int)$defectID; if ( $defectID != 2 ) { // This should not execute, but does. echo "Error: $defectID"; exit; } ?>
View Replies !
View Related
Variable Passed From One Script To The Next?
I'm trying to have a variable passed from one script to the next, and I need to do it without including it in the url (via the ?variable='value'). The variable is populated in the first script when a person logs in, and if they are a supervisor the variable $isallowed is set to true. If they are not a supervisor $isallowed is set to false. The variable needs to be passed to a couple different pages that need to check and see if the person trying to access the page is logged in and a supervisor.
View Replies !
View Related
How To Retreive Url Passed Variable?
I am having a problem retreiving a variable that has been url-encoded from a previous php href link. I have a script that passes a variable, but is it doen right? And, how do I get the variable in the new page? The code is as follows for the passing: Code:
View Replies !
View Related
Hiding Passed Variable In The Address Bar
when i pass values from the link like this <a href="reservation.php?myseldate=1".'-'.$month_curr.'-'.$year_curr."">Click here</a> then in the address bar it shows http://localhost/pankopat/reservation.php?myseldate=1-9-2007 if the user alters the value of date and change 1-9-2007 to 2-9-2007 (or any other thing) then that value gets saved in the database.. Is it possible to hide this value in the address bar or make it uneditable..
View Replies !
View Related
Variable Being Passed From Site Into PhpBB
I am creating an autologin feature where my site members are logged into the bulletin board automaticly the only variable I find that is global is $sAuth it stores the members id #... I can user this to pull the name and password out of the database and set name and password in the forum to eaqual these... is this a security issue? or can $sAuth only be set by script on my site??? I am rather new and want to make sure this variable can not be asigned in another way.
View Replies !
View Related
Showing A Different Page When A Variable Is Passed
this is the code i have just now <? include 'code.php' ?> //where variables are kept <? $welcome = $_REQUEST['welcome']; $leave = $_REQUEST['leave']; if ( $welcome ) echo $page['welcome']; if ( $leave ) { echo $page['leave']; { } else { echo $page['redirect']; }?> what i want to do is, if the variable passed is "welome" i want it to show a welcome page and if "leave" is passed i want it to show a leave page, and when no variable is passed i want it to redirect to a totally different page like this: index.php?welcome Show welcome page index.php?leave show leaving page index.php redirect to a different page
View Replies !
View Related
Passed Variable Not Working In An If Statement
I am setting up a website where students can login and browse their course information and handouts. I have set up a database with there courses in and have managed to get each students courses to appear after they have logged in correctly. The course shows as a hyper link and is passed to a page where an if statement checks which course it is and then directs them to the relevant page. Code:
View Replies !
View Related
Ensure A Variable Passed Through Through URL Exists?
It just donned on me that I need an error message if someone tries to go to a page with a variable in the URL that doesn't correspond to a database entry. For example, http://www.domain.com/poetry.php?piece=4 does not yet exist. Say I only have three poems in the database right now. What are some ways (or the best way) to make sure the variable leads to content or to otherwise display an error message?
View Replies !
View Related
Passed Variable Names In A Function
I am trying to write a function to check for invalid entries in a form. What I want to do is echo an error message with the variable name that is in error. Like so: Code: function nodata($fieldname) { if(strlen($fieldname) <= 1) { echo 'You must enter a value for $fieldname<BR>' return true; } } When I run this I just get: You must enter a value for $fieldname. Is there a way I can can get: "You must enter a value for $username" if I passed the variable $username into the function.
View Replies !
View Related
Assign A New Value To A Variable Passed From An Html Form
I'm trying to assign a new value to a variable passed from an html form to a php3 script. I'm using an if statement to evaluate variable 3 to see if it is equal to a specific string, if it is I'm reassigning variable 2 to be variable2+variable 3. if ($question3!="select days") { $question2=$question2+$question3; } This is the statement. It keeps giving me a parse error and I can't seem to find the right documentation to show me how to combine two string variables.
View Replies !
View Related
Passing A Variable From A Form To A MySql Query
I have a form set up with a dropdown list of values for a field "Genre" in my database I can pass the variable to my php script. I know this because I use: $Genre = $_POST['Genre']; echo "<h1> Query result for Genre = ","$Genre", "</h1>"; And the page prints the appropriate value chosen from the form. I'm trying to use the $Genre variable in a mysql query to select records which match. My mysql query works when I use the following code:
View Replies !
View Related
Variable Passed Through A Function Error - Driving Me Crazy
I have a file that contains a form and passes the results of that form through this function. The function parses the form, checks the fields for content, then enteres the information into a database. Everything is working until I apply the $tblname variable as one of the variables in the function. It is not used anywhere else and for some reason when I change the actual table name to this variable, it is not inserting into the table (I tested the query and there is no table name defined).
View Replies !
View Related
Encrypting Variable Values Passed Thru A Link In A Web Page
I am working on a project in PHP / Mysql on linux platform. The project has a login page where any registered user is supposed to login before he/she can have access to some major functionalities in the project. Since I need to check the authenticity of the user in other secured pages, I have to carry forward the username with which he/she has logged. As I am doing so, the username is appearing in the url. This of course is a major security lapse.
View Replies !
View Related
Image Upload - Using A Variable Passed From A Flash Page
i'd like to pass a variable using post into the following form (that is from php.net) using a variable passed from a flash page (i'm competent in flash but a novice in php)how do integrate: $folder = $_POST['folder']."/"; into the form so that when submit occurs the folder path is passed to upload.php : <!-- The data encoding type, enctype, MUST be specified as below --> <form enctype="multipart/form-data" action="upload.php" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> <!-- Name of input element determines name in $_FILES array --> Send this file: <input name="userfile" type="file" /> <input type="submit" value="Send File" /> </form>
View Replies !
View Related
Save One Of The Values Returned From A Mysql Query As A Variable
I am trying to save one of the values returned from a mysql query as a variable. I want this to be passed to another php page and the variable to be used for a second query. At the moment i am saving the result which is $row[7] as a global variable : global $s_name; $s_name = $row[7]; I then place this in the mysql query on the next page : $result = mysql_query("select * from STUDENTS where (stud_username like '%$s_name%') "); However all the values in this field are retruned, not just the one the was selected in the first query. I have also tried saving it in a session but i get the same. It is as if the $row[7] is returning all the values in that row.
View Replies !
View Related
Variable To Search An Array Created By MySQL Query
I'm trying to use a variable to search an array created by MySQL query. Let's say I have this query: PHP Code: mysql_select_db($database_myconn, $myconn); $query_rs_cars = "SELECT car_id, car_make FROM cars"; $rs_cars = mysql_query($query_rs_cars, $myconn) or die(mysql_error()); $row_rs_cars = mysql_fetch_assoc($rs_cars); $totalRows_rs_cars = mysql_num_rows($rs_cars);
View Replies !
View Related
MySQl Errors Caused By Variables Not Being Passed (global)?
I can connect to database using some search criteria and it displays the results. I have 1 result per page and use pagination which normally works fine but because I am getting a SQL error it won't work....i just get this error message QuoteYou have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND AND bedrooms >= 2 AND location = '' AND type = '' AND `key I only get this error now becuase I set the variable of $min_bedrooms to 2. Before the message got up to near'' and stoped. Code:
View Replies !
View Related
PHP Update Query Mysql: Query Succussful?
I can't seem to successfully test an update query. Below is a piece of code that updates a statistics table. If row today doesn;t exist, a new day must be created. But this doesn't work... thank you for your reply. $today= date("Y-m-d"); $qq="update totals_r set hits_r=(hits_r+1), lang_$lang=(lang_$lang+1), cat_$cat=(cat_$cat+1), rating_$rating=(rating_$rating+1), bussite_$bussite=(bussite_$bussite+1) where date='$today'"; $result_6 = mysql_query ("$qq"); if (!$result_6){ /// IF !ROW_TODAY ==> CREATE NEW DAY $qq_2="insert into totals_r (hits_r, lang_$lang, cat_$cat, rating_$rating, bussite_$bussite, date) values(Ƈ',Ƈ',Ƈ',Ƈ',Ƈ','$today')"; $result_6_2 = mysql_query ("$qq_2"); if (!$result_6_2){ $err_msg_sql_6= mysql_error(); $err_loc_6="$PHP_SELF"." // Query6: update totals_r"; } }
View Replies !
View Related
Query - Create The Mysql Query To Get All Fields
I've a table "article". Any article is of a type in table "type1" or "type2" Each type may be of a model in table "model1" or "model2". Each model can be on a certain make, also in 2 tables, "make1" and "make2". they are a few possibilities. "article" can be of "type1" or "type2" "type1" can be of "model1" only - "type2" can be of "model1" or "model2" "model1" can be of "make1" only - "model2" can be of "make1" or "make2" "article" has "type.id" field (char10). If it start with "my" then it's a "type2", otherwise is a "type1" "type1" has only "model1.id" field. "type2" has "model1" and "model2" fields. If one is filled, the other isn't "model1" has only "make1.id" field. "model2" has "make1.id" and "make2.id" fields. If one is filled, the other isn't so here are the possibilities: article -> type1 -> model1 -> make1 article -> type2 -> model1 -> make1 article -> type2 -> model2 -> make1 article -> type2 -> model2 -> make2 Now, I must create the mysql query to get all fields given the "article.id". Is it possible ? How ? will this work ? in pseudo-code article left join type1 articleid = type1id inner join model1 type1id = model1id //inner because if type1, the model is 1 inner join make1 model1id = make1id //inner because if model1, the make is 1 left join type2 articleid = type2id left join model1 type2id = model1id left join model2 type2id = model2id left join make1 model2id = make1id left join make2 model2id = make2id
View Replies !
View Related
Php Variable And Query
I, writing a script that lookup a record with a lot of field. The first page will show minimum information about that record until one click on a "detail" like that would open another page with more details.I know of to way of doing it. 1. read all the record from the first query and passe the information as variables to the detail page. 2. read the minimum fields with the first page, passe the same key to the other page that would re-query the database and return the "detail information. I'm looking for information on the adantage of one over the other and what make more sense as a server perforance stand point.
View Replies !
View Related
Variable In Db Query
if (isset($_POST["checkbox"])) { $stat = available; status = '$stat' OR '$stat' = '' if the checkbox in my form is checked, this will use the value 'available' in my db query, else it will us the value ''. Is it possible to give 2 values to $stat ? i want my query to search for 'available' and 'under construction' when the checkbox is checked.
View Replies !
View Related
Substring Query Variable
I have a question, as it relates to query strings and all know browsers. If I leave spaces in a substring query; will every browser always automatically add in a %20 to make up for the whitespace? Does anyone know of a browser that does not use %20 to fill in a query string white? Here is an example of what I am talking about: Before http://www.domain.com/page1.html?Hello There After http://www.domain.com/page1.html?Hello%20There The reason I ask is that I am sending a variable from one html page to another using JavaScript and I am using a PHP page (too process form data) with a ereg_replace to convert %20 into a basic whitespace. I know that IE and FF both use the "%20" in query string to automatic fill in whitespace; but I am not sure about other browsers.
View Replies !
View Related
Passing Variable To SQL Query
I am trying to sort out an SQL statement. The below statement will return nothing when it's executed. $date="2007-08-28 15:24:44"; $sql = 'select * from example order by abs( unix_timestamp(`$date`)- unix_timestamp(datetime) ) limit 1'; The problem is when I hardcode in vehicledate,(see below) it works just fine. $sql = 'select * from example order by abs( unix_timestamp("2007-08-28 15:24:44")- unix_timestamp(datetime) ) limit 1'; I assume there is some problem passing variables into SQl statements. Does anyone know how to get this to work. In my PHP script I will be taking in the date from a website so hardcoding it in is not an option.
View Replies !
View Related
Variable Inside Query
Is there a way where inside of this: $spaceq = mysql_query("SELECT SUM(IF(Session1_9 = 'Wild About the Zoo - 9:00',1,0)) AS total FROM Students"); can I substitue 'Wild About the Zoo - 9:00' with a variable assigned to that field?
View Replies !
View Related
Variable Columns In A Query
IS it possible to have a variable/string denoting the column in a search expression? For instance: <?php ini_set ("display_errors", "1"); include 'config.php' include 'opendb.php' $tabsel = $HTTP_POST_VARS['tabsel']; $sess = $_HTTP_POST_VARS['session']; $sorttab = $_GET['sorttab']; $sortvar = $_GET['sortvar']; if (empty($sortvar)) { $sortvar= 'tname' ; } if (empty($tabsel)) { ,.................
View Replies !
View Related
Query Form Variable
the word Dentists is a column (category) in a database... how do I make a form that will create a dropdown menu populated by said database column?...i.e.,so when the submit button is hit the query will execute and the results will be returned for the "category" that was selected? Code:
View Replies !
View Related
Variable Inside To A Sql Query
I want to use a variable inside to a sql query here is an example. PHP Code: $var = $_SERVER['DOCUMENT_ROOT']."/files/data.csv"; $sql = 'LOAD DATA LOCAL INFILE "'$var'" INTO TABLE `data` FIELDS TERMINATED BY '' ENCLOSED BY '"' ESCAPED BY '' LINES TERMINATED BY ' '' mysql_query($sql, $palso) or die(mysql_error()); What am i doing wrong?
View Replies !
View Related
Query Variable As A Database Value
I have a php4 page that displays the results of a mysql query from table 1: echo ($row1[1]); displays "Smith". What I want is to have "$row1[1]" as a value in a different table, call it table 2. Then when I query table 2 I want: echo ($row2[1]); to also display "Smith". Right now it only displays "$row1[1]". I've attempted using the "&" reference tag. Either I was doing it incorrectly or it's not applicable.
View Replies !
View Related
Declare A Variable From A Query...
I have a query: $query = "SELECT newsID, news_headline, news_date FROM news ORDER BY news_date"; I want to declare the news_headline field as a variable. Right now I have: $headline1 = $news_headline; That isn't working, how do I need to do this?
View Replies !
View Related
Printing A Variable From A Query
Ill just post my code rather then trying to explain myself i will just get confused. $query = 'SELECT COUNT(*) FROM performer WHERE performer_type = "Band"'; $result = run_sql( $query, true ); $print= mysql_fetch_assoc( $result ); print $print When I view the page it prints out "Array".
View Replies !
View Related
Split Variable Then Query
I have a query SELECT * FROM mydata WHERE `content` LIKE '%".$_GET['keyword']."%' This then returns results. Is it possible to split the value of the form field, then query each word separate? For example, if I enter "internet design" into the field and then run a query, it would query the words "internet" and "design" separate. So it basically splits the value and queries both words.
View Replies !
View Related
Got A Variable In My Query But It's Not Working...
quite new to php i'm afraid, so this might be a pretty stupid question... Anyway, this is my query (or part of it): $query_recordset_ketcan = "SELECT * FROM programs WHERE zender = 'ketcan' AND date = '$checkdate' ORDER BY id ASC"; and the $checkdate has: <?php $checkdate = date('Y-m-d'); ?> but it just doesn't seem to work... The idea is that the $checkdate takes the date in that format from the server & compare that with the value in the database.
View Replies !
View Related
MySQL Query - 2 Steps In 1 Query?
I have two tables and the first one contains 2 main fields- 'user_id' and 'username'. The second table contains 2 main fields- 'poster_id' and 'message'. And what I need to do is lookup the user_id from the first table with the username, then pull * from the message_table if the poster_id matches the value pulled from the first table. Now, I got this working without a problem at all but I had to use 2 queries to do it (1- pull the user_id from the first table by matching it with the username, then 2- using the first id, pull everything from the second table that matches it). Is there an easy way to do those 2 steps in 1 query? I know there must be some way since this seems like a fairly simple and routine problem, but I can't find it online or in any books I have here.
View Replies !
View Related
Count Query In Mysql Query
Is it possible to retreave all data from 1 table. and count a number of records where 1 row has the same number as id of the main table? example Table categories id name 1 blah 2 hello Table Threads id name categoryid 1 first 1 2 mid 2 3 noon 1 4 blah 1 5 roar 2.
View Replies !
View Related
Entire Query String As Script Variable
How would I pull the query string of an URL into my PHP script for use as a variable inside the script? For example - URL is http://www.mydomain.com/hub.php?ref...bob&lname=smith In my hub.php script, I want to set a variable $foo = "ref=affiliate1&fname=bob&lname=smith"; (or whatever the actual query string happens to be)
View Replies !
View Related
|