Can I Parse A SQL Result As A Php Include?
I'm trying to use a MySQL database as a repository of common classes and functions, and would like to be able to get the resultant string, addslashes, and then actually execute the string as if it was an included file. I can do this by writing a temp file, then including it, and then deleting it, but any speed benefits are lost. Is there a way to actually parse the results as if they were an external include file? Thanks for the help.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
- Ignore Parse Error On Include?
- Include A Php Script Without Causing A Parse Error
- Function Defined In Include File - Parse Error
- Parse Error: Parse Error, Unexpected T_STRING, Expecting ',' Or ';'
- Parse Error: Parse Error, Unexpected T_IF, Expecting ',' Or ''
- Displaying Result 1-8, Then Result 9-17 Etc.
- Parse Error When Trying To Parse XML
- Include Or Virtual Include: Neither Work For Subfolders
- Parse Error: Parse Error, Unexpected T_LNUMBER
- Parse Error</b>: Parse Error, Unexpected T_CONSTANT_ENCAPSED_STRING I
- Parse Error: Parse Error, Unexpected T_STRING
- Parse Error: Parse Error, Unexpected T_STRING,
- Parse Error: Parse Error, Unexpected T_ELSE....
- Parse Error: Parse Error, Unexpected T_LNUMBER,
- Paging (Parse Error: Parse Error, Unexpected '.' )
- Parse Error: Parse Error, Unexpected T_STRING
- Parse Error: Parse Error, Unexpected T_ELSE
- PHP Parse Error: Parse Error, Unexpected T_VARIABLE
- Nesting Result Loops Within Result Loops Possible?
- Parse Error: Parse Error, Unexpected '='
- Parse Error: Parse Error, Expecting `','' Or `';''
- Parse Error: Parse Error, Expecting `']''
- Parse Error: Parse Error, Unexpected $end
- Parse Error: Parse Error, Unexpected $ In
- Parse Error: Parse Error, Expecting `','' Or `'''
- Error Says Can't See Include File, Yet Executes Some Code On Include File
- From SSI Include To PHP3 Include
- Can't Include 'http...foo.php', But Can Include 'http...foo.txt'
- SQL Last Result
- Outputing Result Once Only
- Result Using Two Variables
- Weird Result? Php 4.4.0
- Getting Result From Mysql
- To Display Nothing If Result Is None
- Result Set Problem
- Oracle->not Same Result From Php And From Sql*plus
- Paging Through Result Set
- Pulling One Result From DB
- Result Handler Set?
- Search Result Help
- How Could I Paginate The Result Set?
- Mysql_query Result
- Result Sets
- Incorrect Result
- Looping A Result
- Add Sql Result To An Array
- Maths Result...
- Parse XML With PHP
- How To Parse A Url Better..
Ignore Parse Error On Include?
Is there a way to ignore parse errors when calling an include? That is, the script calls include("file.php"), but if file.php has a parse error, the script just ignores the include and moves on. If you need specifics, I'm running an AIM bot and I have it so I can update part of the bot's functionality while it's still running. Code:
Include A Php Script Without Causing A Parse Error
i am trying to find a way of doing this that won't generate a parse error,the problem arises from calling a file that has php code inside that file, when you do it the way below it generates the error and I was wondering in thier is a way around this or another way I can do this. <?php if ($action == "addproduct") { include("templates/templ_addproduct.php"); } if ($action == "viewproducts") { include("templates/templ_viewproducts.php"); } else //state that neither is showing up { print "neither addproducts or viewproducts was selected"; } ?>
Function Defined In Include File - Parse Error
I created a function to handle the connection to the database and put it in an include file so I wouldn't have to keep repeating that code in the various files connected to a system I'm creating and to make it easier to change the values of the database variable and password variable. I can't get it to work though and keep getting a parse error on "line 2" which is the function defining line. Is there something about defining a function in an include file that I don't know. I'll list the code of the entire include file below. Everything except for the function defining line is an exact duplicate of code that was already working before. Code:
Parse Error: Parse Error, Unexpected T_IF, Expecting ',' Or ''
I'm playing around with PHP's imap functions and I'm encountering a syntax error that I can't figure out completely. Quote: Parse error: parse error, unexpected T_IF, expecting ',' or '' in /home/kingmike/docs/WEBMAIL/inbox.php on line 53 PHP Code:
Displaying Result 1-8, Then Result 9-17 Etc.
I dispaly the results from the database like this. <? while ($row = mysql_fetch_array($prod_result)) { $small = $row[0]; echo"<td align=center><img src="produkter/hardware/decks/$small"></strong></td>";}?> But if there are more than 8 results, I wnat to dispaly the first 8 on one page, then the next 8 on the next page...How can this be done?
Parse Error When Trying To Parse XML
Trying to read in values from XML document and put them into an array in PHP, so I could use the different values to use in my PHP script... I am a beginner, so I decided to look and run some examples... well I always get this error in the 1st line... for some reason it doesnt liek the first line at all. PHP Code:
Include Or Virtual Include: Neither Work For Subfolders
my includes files are all in my /ssi directory. I have many subfolders that call those includes files. Let's say I have a file like this: /news/world/asia/thailand/index.php In order to (relatively) call a file in the /ssi directory I have to use the following code: <?php include ("../../../../ssi/html-lang.htm"); ?> This is ridiculous. Everytime I make a new subfolder I don't want to have to add "../" to it. I heard about "virtual" includes but I'm not sure the syntax I'm using is correct (all I do is put 'virtual' after 'include'). Is there something I'm missing? Do I have to change the .htacess file? Help me please I'm going crazy. I don't want to resort to absolute referencing...
Parse Error: Parse Error, Unexpected T_LNUMBER
what's wrong with this code? line 19: if($_POST['miners']*500+$_POST['magicians']*800+$_POST['knights']*1200+$_POST['rangers']*1500>$fdatabase['gold']){echo("false!");} I got error: Parse error: parse error, unexpected T_LNUMBER in /home/www/xyz.php on line 19
Parse Error: Parse Error, Unexpected T_STRING
I have edited a php script to pick up the data from a webform and convert it into a email and when i submit it i get a error..... Parse error: parse error, unexpected T_STRING in /home/nas01l/f/flexamatic.com/user/htdocs/estore/sendmail9.php on line 6 the php is:
Parse Error: Parse Error, Unexpected T_STRING,
Can a class define a constant as Java or C does? I tried to define a constant by define("AMAZING_VALUE", "1997"); but it prompts: Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}'
Parse Error: Parse Error, Unexpected T_ELSE....
The code is: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Club</title> </head> <style type="text/css"> body {margin : 0px;} </style> <body bgcolor="navy"> <font color="white"> Welkom in de winkel. Wat wilt u doen?<br> <form action="club.php" method="post"> <input type="radio" name="keuzewinkel" value="1">Voer kopen<br> <input type="radio" name="keuzewinkel" value="2">Bijproducten kopen<br> <input type="radio" name="keuzewinkel" value="3">Medicijnen kopen<br> <input type="radio" name="keuzewinkel" value="4">Praatje maken met de verkoper<br> <input type="radio" name="keuzewinkel" value="5">Duiven verkopen / kopen<br>  <br> <input type="submit" value="Verder"> </form> <? if (isset($submit)) { if ($keuzewinkel == Ƈ') include('koopvoer.php') else ($keuzewinkel == ƈ') include('koopbijproducten.php') <-- Line 25!!!! else ($keuzewinkel == Ɖ') include('koopmedicijnen.php') else ($keuzewinkel == Ɗ') include('chatverkoper.php') else include('koopduiven.php') } ?> </body> </html>
Parse Error: Parse Error, Unexpected T_LNUMBER,
i got a proplem with my array the error message is : Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in D:xampphtdocsworksmartcontractorssites est.php on line 5 PHP Code:
Paging (Parse Error: Parse Error, Unexpected '.' )
I am trying to page my database records using php and i have written the script but somehow it is giving some weird error somewhee towards the end of the script. can anyone just check the code and tell me whether this will work(give a little attention to the A HREF tag) and how to remove the error that i am getting . The error that I am getting is "Parse error: parse error, unexpected '.' in c:webpaging2.php on line 62" code:
Parse Error: Parse Error, Unexpected T_STRING
keep getting this errorParse error: parse error, unexpected T_STRING in order_fns.php line 91. the code is below for the file and I've indicated line 91 <?php function process_card($card_details) { // connect to payment gateway or // use gpg to encrypt and mail or // store in DB if you really want to return true; } function insert_order($order_details) { global $HTTP_SESSION_VARS; //extract order_details out as variables extract($order_details); //set shipping address same as address if(!$ship_name&&!$ship_address&&!$ship_city&&!$ship_state&&!$ship_zip&&!$ship_country) { $ship_name = $name; $ship_address = $address; $ship_city = $city; $ship_state = $state; $ship_zip = $zip; $ship_country = $country; } $conn = db_connect(); //insert customer address $query = "select customerid from customers where name = '$name' and address = '$address' and city = '$city' and state = '$state' and zip = '$zip' and country = '$country'"; $result = mysql_query($query); if(mysql_numrows($result)>0) { $customer_id = mysql_result($result, 0, 'customerid'); } else { $query = "insert into customers values ('', '$name','$address','$city','$state','$zip','$count ry')"; $result = mysql_query($query); if (!$result) return false; } $query = "select customerid from customers where name = '$name' and address = '$address' and city = '$city' and state = '$state' and zip = '$zip' and country = '$country'"; $result = mysql_query($query); if(mysql_numrows($result)>0) $customerid = mysql_result($result, 0, 'customerid'); else return false; $date = date('Y-m-d'); $query = "insert into orders values ('', $customerid, ".$HTTP_SESSION_VARS['total_price'].", '$date', 'PARTIAL', '$ship_name', '$ship_address','$ship_city','$ship_state','$ship_ zip', '$ship_country')"; $result = mysql_query($query); if (!$result) return false;
Parse Error: Parse Error, Unexpected T_ELSE
I got the following error in my page Parse error: parse error, unexpected T_ELSE in line 25 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Club</title> </head> <style type="text/css"> body {margin : 0px;} </style> <body bgcolor="navy"> <font color="white"> Welkom in de winkel. Wat wilt u doen?<br> <form action="club.php" method="post"> <input type="radio" name="keuzewinkel" value="1">Voer kopen<br> <input type="radio" name="keuzewinkel" value="2">Bijproducten kopen<br> <input type="radio" name="keuzewinkel" value="3">Medicijnen kopen<br> <input type="radio" name="keuzewinkel" value="4">Praatje maken met de verkoper<br> <input type="radio" name="keuzewinkel" value="5">Duiven verkopen / kopen<br>  <br> <input type="submit" value="Verder"> </form> <? if (isset($submit)) { if ($keuzewinkel == Ƈ') include('koopvoer.php') else ($keuzewinkel == ƈ') include('koopbijproducten.php') <-------- line 25 else ($keuzewinkel == Ɖ') include('koopmedicijnen.php') else ($keuzewinkel == Ɗ') include('chatverkoper.php') else include('koopduiven.php') } ?> </body> </html>
PHP Parse Error: Parse Error, Unexpected T_VARIABLE
I'm writing a fairly simple php script and I keep getting the message "PHP Parse error: parse error, unexpected T_VARIABLE". I know that means I made a simple mistake somewhere, but syntax highlighting and checking have revealed nothing and I certainly not catch it with my own eye. I reformatted the whitespace to spaces and newlines only, so it has to be something that shows up on the screen. here's the PHP portion in its entirety: <%php $socket = @mysql_connect("mysql","database","****"); if (mysql_select_db ("comments")) { $sql = "SELECT * FROM register"; $query = mysql_query($sql, $socket); while($data = mysql_fetch_object($query)) { echo "<TR><TD> $data->name $data->email $data->aim $data->known</TD></TR>"; } } %> There is no other scripting on the page. The error is on the line with "$socket = @mysql_connect...". Could I have the ASP-style tags wrong?
Nesting Result Loops Within Result Loops Possible?
I'm looping through a query, and inside the while result output, I am trying to loop through a second query (created from the 1st query's row results). I have checked that both queries return info. I can see that the 1st while result output works fine, but when I get to the inner while result output, it never returns any rows (nothing in the while loop evaluates). So, IS it possible to nest one query's output loop within another, or am I doing something wrong?
Parse Error: Parse Error, Unexpected '='
I'm not sure where to look up the answer to this question myself, so maybe you can help me. The following line of code works fine with php5: function CheckMappings(&$badMappings=array()) On a system with php4 the following error is thrown: Parse error: parse error, unexpected '=', expecting ')' in <phpfileon line 42 Now I would like to know, what the problem is. Is it the '&' or the default value assignment or a combination of both? Where would I find documentation on the differences in the versions of php? Is there a good site? Maybe a table with a feature comparison?
Parse Error: Parse Error, Expecting `','' Or `';''
I'm getting the following error Parse error: parse error, expecting `','' or `''' in /home/notarywe/public_html/php/update2.php on line 108 Here is line 108 <input type="text" name="ud_first" value="<? echo "$first" size="20"?>"></td>
Parse Error: Parse Error, Unexpected $end
I recently created a script for user verification, solved my emailing issues, and then re-created the script in order to work well with the new PHP 5 that I installed on my server. After submitting user information into my creation script, I get the following error from the page that is suppose to insert the user data into the database, create a code, then send an email out for verification. Parse error: parse error, unexpected $end in c:wampwww hreadcreateadd2tbl.php on line 31 Below are the files in which I am using: add2tbl.php <?php require "mailfunctions.php"; $username = $_POST['username']; $md5password2 = md5($_POST['pass2']); $email = $_POST['email']; $md5password = md5($_POST['pass']); if(isset($_POST['username'])) { if ($md5password == $md5password2) { $db = dbc(); $code = codegen(); $user = insertuser($username, $md5password, $email, $code); if ($user == FALSE) { die("There has been an error in adding you to the Database. Please EMail the admin."); } else { echo "<b>Passwords do not match!</b> "; } include("/top.html"); $mail = mailauth($username); if ($mail) { echo ' <p class = "subtitle">Success! Check your email.</p>' } else { echo ' <p class = "subtitle">We are sorry. The request did not go through successfully due to an error in the Mail server. Please contact the Admin.</p>' } include("/bottom.html"); } ?> mailfunctions.php <?php function dbc() { mysql_connect(localhost, "root"); mysql_select_db("ehartwig1"); return TRUE; } function codegen() { $code = rand(10000000000000,999999999999999); return $code; } function insertuser($name,$md5password,$email,$code) { $query = "INSERT INTO threadauth (username, password, email, authcode) VALUES ('{$name}','{$md5password}','{$email}', '{$code}') or return(FALSE)"; $result = mysql_db_query($query); return $result; }
Parse Error: Parse Error, Unexpected $ In
I have just solved the last problem. But now i get the error message Parse error: parse error, unexpected $ in /homepages/12/d214897219/htdocs/adam/create_thumbnails.php on line 58. I dont know how to solve this. Code:
Error Says Can't See Include File, Yet Executes Some Code On Include File
I am using an include_once() command to include a file that sits a level above the file view.php. when the code is run, I have an error as follows: Warning: include_once(../common.php) [function.include-once]: failed to open stream: No such file or directory in C:Program Files.. view.php on line 2 Warning: include_once() [function.include]: Failed opening '../ common.php' for inclusion (include_path='.;C:Program Filesxamppphp pear') in C:Program Files...view.php on line 2 The include command is simply: include_once(../common.php) - the '../' before the 'common.php' to indicate a level above the current file level. Is this right? I could not find a resource to confirm this. The strange thing is that while the error seems to imply that the calling file, view.php cannot 'see' the common.php file, other functions called from the 'common.php' file executes correctly and on the same calling file/page (view.php). Appears to the a double take - quite confusing -
From SSI Include To PHP3 Include
Im trying to convert my pages to php and have a problem, how do I change from SSI include (.shtml) to PHP include (.php3) so that I still can have the last line in my script, (?start=11&end=15 after the .php3) I have tried this: <?php include ("ssi-top10-15.shtml?start=11&end=15") ?> and it didnt work, I used to have it like this: <!--#include virtual="ssi-top15-25.shtml?start=16&end=30" --> This works, but it leaves out the scipt part: <?php include ("ssi-top10-15.shtml") ?>
Can't Include 'http...foo.php', But Can Include 'http...foo.txt'
This seems weird, but when I use the following code, include 'http://www.foo.com/includes.php' includedfunction(); I am told that it is a call to an undefined function, but 'includedfunction' is on the server. the following includes work fine, and the run the called function with no trouble: include 'http://www.foo.com/includes.phtml' include 'http://www.foo.com/includes.txt' all three include.php,.phtml & .txt are on the server and are exactly identical. I am running php version 4.1.1.
SQL Last Result
When querying and doing a loop I want to specify that the last result of the loop does not include a horizontal line. How would I do this?
Outputing Result Once Only
Hi, I have a php script that looks up mysql records, on the basis of keywords entered by the user. The records are in tables making up a message board system, and the search works both for 'top-level' messages, and for replies. The results lists the 'top-level' message (ie the entire thread), even if the search matched text in a reply. However, I am having a problem making sure the thread is not listed more than once if the search matches several replies in the same thread. At the moment, the search looks up all the rows containing the search text, then the message starting the thread if the search has matched a reply, and the results are output in a while loop. I have tried making a long string containing all the id's of the displayed rows, usingsomething like $displayed .= _$row[id]_ in the loop, and then ereg("_$row[id]_", "$displayed", $array) earlier in the loop to see if this message's thread id is already listed, and skipping it if it is. However, I can't seem to get this to work. Also, this seems like a really inefficient workaround. Is there a better way to do this?
Result Using Two Variables
Probably a real simple solution but I can't for the life of me work it out. I have: $pollitem_1 $pollitem_2 $pollitem_3 $pollitem_4 if I do a for loop for the amount of items, is it posiible to have a variable for the number after the _ ? e.g....
Weird Result? Php 4.4.0
I have a variable v with the value -1. After v++ it has the value "" not 0. Since I am using it for a subscript, the "" value is not overwriting the 0 element of the array as desired. Should v++ ever give a non-numeric value?
Getting Result From Mysql
I am using this code to get some data from a mySQL database. Which seems pefectly valid to me. Here it is: Code:
To Display Nothing If Result Is None
Below is the script for displaying the data from a table. Is it possible that if there is no data, then the whole table should not display and not only the result field. Code:
Result Set Problem
I am new to programming in PHP however, this should be a pretty straight forward answer. I have three queries that I am pulling for a content form page. 1) The Author List 2) The Content Page (pulls the PK, Title and the Description of the content. 3) The Category List When I attempt to pull the data the only result set I get back is from the Item #1 query above. Now, I made sure that there is data in the tables, but I still get no data back for the other two queries(????) Is there something that I missing when connecting to PHP/MYSQL? Do I need to take some additional steps?? Any help would be greatly appreciated. I've been struggling with this problem for several hours now scratching my head why this is. :-) // here is the PHP Code I am using <?php $db = mysql_connect("$DB_SERVER", "$DB_SERVER_USERNAME", "$DB_SERVER_PASSWORD"); mysql_select_db("$DB_DATABASE",$db); //result set 1 - get members $result_M=mysql_query("SELECT * FROM tblMembers",$db); $myrow_M=mysql_fetch_assoc($result_M); //result set 2 - get content ID $result_C=mysql_query("SELECT * FROM tblContent WHERE contentID=1",$db); $myrow_C=mysql_query($result_C); //result set 3 - get categories $result_Cat=mysql_query("SELECT * FROM tblCat",$db); $myrow_Cat=mysql_query($result_Cat);.....
Oracle->not Same Result From Php And From Sql*plus
Here is my query, ran from oracle sql*plus: SELECT mrbs_room.id, start_time, end_time, name, mrbs_entry.id, type FROM mrbs_entry, mrbs_room WHERE mrbs_entry.room_id = mrbs_room.id AND area_id = 101 AND start_time <= 1076068800 AND end_time > 1076065200 Here is the correct result : SQL> Connected. ID START_TIME END_TIME NAME ID T ---------- ---------- ---------- ---- -- - 82 1076065200 1076068800 test 41 I Ran from php, I got this : ID START_TIME END_TIME NAME T ---------- ---------- ---------- ---- -- - 41 1076065200 1076068800 test I the two ID fields are named with their table name, but php keep the second value and display it as the first one.
Paging Through Result Set
Using PHP to query a MYSQL db, I am attempting to portion the result set on multiple pages. I see this technique used on this site. example: If a user query yields 30 results I want to display 5 results at a time allowing the user to page forward or back through the results.
Result Handler Set?
I'm getting an error which get's reported something like "can't save result handler blabla".. .. i didn't note the exact error at the time and i can't bring it back cuz i deleted my whole database and started from scratch.. anybody know what this is about?? i'm pretty sure it's something to do with mysql.. it shows with mysql_error().
Search Result Help
I am trying to do the following with my search script that looks for records in a mysql table. The following is an example of what I am trying to do. Text being searched: -- The brown fox jumped over the green fence then jumped into the web monitor. It was hurt so it jumped backwards and fell on its! -- The word we're searching for "web". The results should look like -- ...then jumped into the *web* monitor. It was... -- Are there any functions out there that will do this? Or what would it take to make one?
How Could I Paginate The Result Set?
I would like to do something like this: select * from myTable where ... pagesize 10 page 1 How could I do it elegantly in: 1. PHP+MySQL before MySQL 5 (without stored procedures) 2. MySQL alone (with stored procedures)
Mysql_query Result
I have a small problem with PHP and MySQL. I want to know how to check if a value is existing in a MySQL database using PHP. The code is below: PHP Code:
Result Sets
I am having alot of trouble trying to append a result set using a loop. I am taking a number from options from a select option list in a form and for each of these i want to execute the statement. for($y=0; $y<$totaltown; $y++) { $result=select statement} and then out put the info using a while loop. My problem is the result set keeps overwriting itself until it produces 0 results. I have tried using $result+=$result but it is then no longer a ersult set. The code i have works fine when i only want to produce all hte results on one page but i am paging the results which is where my problem lies ie LIMIT.
Incorrect Result
i try to insert a text in a database (mysql) in this text, there are php code i want to display... i use <code>...</code> to do this job str = $_POST['texttutoriel']; $str = preg_replace_callback('`<(code|url|img)>(.+?)</1>`si', 'bbcode', htmlentities($str)); $str = mysql_real_escape_string($str) my bbcode function: function bbcode($m) { switch($m[1]) { case 'code' : return '<div class="code"><pre>'.$m[2].'</pre></div>' break; //... } }
Looping A Result
Im new to PHP and MySql, Im trying to setup a really basic news script for me to use for my site 2design4.com. PHP Code:
Add Sql Result To An Array
I am trying to add the results of a query (specifically a particular field's value) to a new array. The result is either an empty array or the last row in the query result instead of all the rows. Code:
Maths Result...
I have a mathematical calculation, and for some reason if i put "1" into the input this is the result i get : Quote1 Muscle Building sessions giving you a strength gain of 4.99999999999E-5. I have put a script in to cut the decimals so that it'll only go as far as 5 decimals but it still keeps coming up... $DecimalRemovalStrengthresult = number_format($GainTotalStrength,5); $DecimalRemovalStrength = number_format($NewStrength,5); That is what im using to strip the number down so it should only show "4.99999" If i don't put "1" and I put say anything above 1 it'll work fine and only show a figure of 5 decimal places such as 4.99000. So what is actually happening to the number to come up with 4.99999999999E-5 ? Does the value mean infinite number or something else?
Parse XML With PHP
Hi, i'm using the PHP code form melonfire at : URL My question is : So far, my xml code has been in the form like 1) <title>The Hobbit</title> <Pages>359</pages> and everything seems fine. But i'm wondering if its also possible to have the xml code like 2) <title="The Hobbit" Pages="359" /> Would it be possible to parse XML with php when the XML code is like the second example??if so what would I have to change in the PHP code?
How To Parse A Url Better..
Currently I have $ref = $_SERVER["HTTP_REFERER"]; $ref = strtolower($ref); $ref = parse_url($ref); $ref = eregi_replace("www.", "", $ref["host"]); which will result in domain.com Is there a faster way / better way to do this?
|