Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Echoed The MySQL Query


I'm currently building a time booking system, and what I have done is created a few tables in my database and populated these with some test data.

The problem I'm having is that I know for a fact that when I click on the 1st Sept for example the first couple of time slots have been taken,so for a test I've used the word 'booked', this works, if the time slot is not taken then it should say 'available', this doesn't do it.

I have echoed the MySQL query and I've test this on the MySQL console and it works, but yet it says 'booked' when its really not.




View Complete Forum Thread with Replies

Related Forum Messages:
Being Echoed
I have following html before head of html in my page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

View Replies !
HTML Echoed Out
Does anyone have any idea why when I echo HTML it doesn't parse the HTML but outputs the code? I even added two <h2> tags manually and it works, so it's just from pulling it out of the database.

PHP Code:

<?php
//The <h2>s work fine but the array variable being outputted doesn't parse the HTML
echo "<h2>".$profile['biography']."</h2>";
?>

View Replies !
HTML Echoed
I have the notion that everything is more secure if everything is in php, and nothing is in html. Perhaps I am mistaken in my understanding. But, because I believe that everything would be more secure in php, I am trying to take an html form, and find a way to ECHO it in php.

It is an example form that I found in google.  It works just fine as HTML, and it is a submit to a php script which will receive the data through $POST. But, I am trying to build all the HTML in $form and then echo it. I am not having much success. Code:

View Replies !
Formating Echoed Table
How would I format the table with borders backgrounds etc.

printf("<table>");

do
{
$myrow = pg_fetch_row($result_set,$rows);
printf("<tr>");
for ($i=0; $i < $count_ch; $i++)
{
printf("<td>");
printf($myrow[$i]);
printf("</td>");
}
printf("</tr>");

$rows++;
}
while($rows < $rowsnum);
}

View Replies !
Last Twelve Hours Echoed
I am so tried but can someone help and show me a basic way to only display the last twelve hours of results from the MySQL? I have a column with the time, how do I only show the last tweleve hours?

View Replies !
Variable In A Php Echoed Form
At the moment it prints " /> and I lose the variable.

<?php
echo '<form action="formt.php" method="post">
<input type="hidden" name="uname" value="$_SESSION["username"]" />
<input type="submit" label="submit"></form>'
?>

View Replies !
Saving Result Of Function Without Being Echoed
I am trying to save the function "rand(1, 1000000)" in a variable but when I am for example trying:

$randomnumber = rand(1, 1000000);

it is executing it right ahead while when i try

$randomnumber = "rand(1, 1000000)";

or

$randomnumber = 'rand(1, 1000000)'

It is saving rand(1, 1000000) as variable.

But what I need is a variable saving the result of rand(1, 1000000) so the number does not change either.

Any ideas how I would do this?

View Replies !
Accessing Session In A Php Page Echoed By Fstream
if I load a php page from controller.php like this:

$handle = fopen("http://localhost/MvCphp_1.0/View/maincatgory.php", "rb");
               echo stream_get_contents($handle);
               fclose($handle);

then the created session, in the file where I am running the above code,  for instance $_Sesssion['hr']='ge'; will not be accessible in echoed file above "maincatgory.php" I don't know why? and I want to know how can I access...?

View Replies !
Get A Database Stored Date Echoed On A Website
I'm trying to get a database stored date echoed on a website. The problem is it won't show up. This is the code piece getting the rows:

$row3 = mysql_fetch_array($result);

This is the piece declaring date to $actualdate:

$actualdate = $row3['date'];

This is the piece echoing the date:

echo $actualdate;

I'm sure I'm doing some damn mistake here, it's probably really easy for you other guys to solve.

View Replies !
How To Create A Hidden Field Variable From An Echoed PHP Figure?
I have a PHP script on a shopping cart summary page that creates an invoice number and then echoes it to the page. This page, when submitted, will go to the shopping cart processor.

The echo portion of the script is working properly, it generates the number as intended.

My problem is that, not being very experienced in PHP, I want the invoice number not only echoed (which it is doing properly now), but also to populate a value in a hidden field that is submitted to the shopping cart processing page. My question is how do I populate the hidden field with the figure that is now being echoed in the script below?

The script that generates and echoes the invoice number is as follows:

<?php
echo "SA"; //department code
echo date ("mdy"); //date generator
// begin counter this reads figure from "count_file.txt"
if (file_exists('count_file.txt'))
{
$fil = fopen('count_file.txt', r);
$dat = fread($fil, filesize('count_file.txt'));
echo $dat+1;
fclose($fil);
$fil = fopen('count_file.txt', w);
fwrite($fil, $dat+1);
}
else
{
$fil = fopen('count_file.txt', w);
fwrite($fil, 1);
echo &#391;'
fclose($fil);
}
// end counter
?>

The hidden field is as follows:

<input name="Invoice_Num" type="hidden" id="Invoice_Num" value=" ">

I would like the value in the above to reflect the invoice number that is echoed by the above PHP script.

View Replies !
Nest One Mysql Query Within Another (for Cross Referencing Another Table In The Middle Of That First Query)?
How do i nest one mysql query within another (for cross referencing another table in the middle of that first query)? for example:

i am referencing a table with news posted by members and in the middle of that reference i want to reference an up to date version of their email address as listed in their profile (in case they change it after posting a news message).

View Replies !
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(&#391;',&#391;',&#391;',&#391;',&#391;','$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 !
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 !
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 !
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 !
PHP Saying Error In Mysql Syntax, But Written My Mysql Query Browser!
I have a basic db that I access with MySQL query browser. Everything
seems fine to me but I am using this db as part of a php shopping
basket and when I try to add an item I get:

Notice: Query failed: You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near '>function.extract]: First argument should be an
array in functions.inc.php on line 31
Notice: Undefined variable: price in functions.inc.php on line 36
Notice: Undefined variable: price in functions.inc.php on line 39
Notice: Undefined variable: total in unctions.inc.php on line 39

I'm assuming the last three are caused by this problem as price should
be passed to the cart, and total is worked out using it. However
although I know mySQL code it was the MySQL query browser that
actually generated the code and I cannot see a way to view or debug
the code.

The db has one table in it which is made up of id, name, subname,
desc, and price.

The code in the php file that is being referred to is:

View Replies !
Fatal Error: MySQL Error: 2013 : Lost Connection To MySQL Server During Query
I am getting the following error:

Fatal error: MySQL error: 2013 : Lost connection to MySQL server during query

View Replies !
Query MySql Using PHP
I've created my first search form and it seems everything is working pretty well. However, since I am very novice in scripting in general, I'm having one problem that I can't seem to unearth an answer to. Perhaps someone could easily offer the answer:

my query asks to select a 2 char state code or a 5 digit zip code in order to obtain results desired. In testing, if I enter a state code, it brings up only the state requested. However, when I enter a zipcode, I get the wrong results. I'm sure its the "LIKE" that is throwing this off. Here is the query portion of the script:

$result = mysql_query ("SELECT * FROM fish_dealers
WHERE Zip = ´$Zip%´

OR State LIKE ´$State%´
");


Can anyone give me a clue?

View Replies !
AND And OR In MySQL Query
I've build a query from a php form where people van select more results for a cell wich can only contain one value Here's my query:

SELECT * FROM person WHERE color_eye = ('brown') OR color_eye = ('black') AND color_hair = ('Blonde')

Everything after the "OR" will be ingnored. So how can I tell MySQL I want all the brown and blacked eye?? Without the AND it works fine, but in real the query is way longer with multiple AND's.

View Replies !
Php/mysql Query
I want to display the users name on the pages when they have logged into my site. i have done it one way that is to take what they type in the login form and post it on the page and that works fine. only one problem and its more of a preference than a problem but the way i did it takes exactly what they type say "username" and posts that so if they type "UsErNaMe" it will post it like that. i want to show the name exactly as they make it when signing up. im guessing i have to query the data base... mine being MYsql. PHP Code:

View Replies !
Mysql Query With * And +
im trying to return all results that come from or went to certain extensions on our phone logging system but i don't want to return any that have a src or dst that contain a * or a +. This is the where statement i have that is not working Code:

View Replies !
Getting MySQL Query
I took some info out of my database.  I want to display an error page if their are no rows in the database.  How would I go about doing that. I have this:

$query = I execute my query here.  Taken it out so you don't connect to my database Muahahahhaah

$row = mysql_fetch_row($query)

if ($row == '')
{
echo 'Their is nothing in the database!';
}else{
echo 'Yes, the database does home info in it.';}

What would I put to make this work?

View Replies !
Mysql Query In PHP
i got a strange problem with a simple mysql query in php. simply, it doesn't work on my page (while it does through phpmyadmin):
there's the query:
$sql="
SELECT operatore, azione, COUNT( azione ), SUM ( numore )
FROM `utentiAzioni`
WHERE completata = &#391;'
GROUP BY operatore, azione ORDER BY operatore
"
the error message is:
"You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near '( numore ) FROM `utentiAzioni` WHERE completata = &#391;' GROUP BY
a..."

any idea?

View Replies !
Query Log For MySQL
Is there a simple way to create a query log for mySQL? I've been asked^h^h^h^h^h told to add a layer of auditing on an existing application.

It's unlikely that this audit log will ever be looked at so a listing of sql queries would probably suffice (it'll be big enough to impress anyway).

View Replies !
PHP And MySQL Query
If I put this code into a page by itself with the db login info, it works just fine. But if I put it into another file that contains other PHP code, the select menu shows up with rows of "-" and not the values contained in the db. I didn't want to make a long post, so here is a snippet of code. Is there anything I should be looking out for? Should I post all of my code (it's 159 lines long). PHP Code:

<?php
    print "<select name="Top">";
    $rows = $db->getAll('SELECT isbn, artist_name, album_title, date_format(release_date, '%M %d, %Y') as release_date, date_format(add_date, '%M %d, %Y') as add_date, description, price, image FROM lounge');
    foreach ($rows as $row) {
    $artist_name = stripslashes($row[artist_name]);
    $album_title = stripslashes($row[album_title]);
    print "<option value="$row[isbn]">$artist_name - $album_title</option>";
}
    print "</select>";

?>

View Replies !
Mysql/php Query
If I have a table in a database that has this info:

key - name - favorite
1 - john - 2
2 - judy - 3
3 - joe - 1

the favorite icecream table is this:
key - flavors
1 - vanilla
2 - chocolate
3 - strawberry

how do i do a query to display that judy's favorite is strawberry. obviously this is a simple example. i am doing working on something that is much more complex than this, but if anyone can give a hint i can apply to the thing i am working on.

View Replies !
Php Mysql Query
$query = mysql_query("SELECT * from messages WHERE roomid='$rid' & WHERE to='all'") or die (mysql_error());.

View Replies !
Mysql Query
I am using the script below and i keep getting : No such username . . . and the info the database is there Code:

View Replies !
Mysql Query Using OOP
example.

$query="select * from users where user_id='$userid'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
echo $row[name];

View Replies !
Need Help With Basic Php Mysql Query
$z = "goodBMW"; the word goodBMW is no where to be found in in the table times. but it will echo every single row thats in that table and it doesend sort between Group 1 and Group 2 where the hell is my query wrong.

View Replies !
Problematic MySQL Query
Would anyone be able to help me with the following MySQL problem. I am
trying to extract all of the users who are not on vacation for a given
date. I am using a NOT IN statement, however, I need to have a more
advanced query than a simple one. What I need to do is as follows
SELECT users.user_id,...

View Replies !
MySQL Query Quandry
I have a simple need to go into a 4 column table and based on the content of the first 3 print the content of the 4th. In other words if column1 = a, column2 = b, and column3 = c then print "dog" from column4. This will be the action for a short form that allows the user to make 3 choices that will determine a link. I have this from another script that I'm trying to modify:

mysql_select_db('search_links');
$query = "select * from links ";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo '<p>Number of books found: '.$num_results.'</p>'
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo '<p><strong>'.($i+1).'. Title: '
echo htmlspecialchars(stripslashes($row['type_prop']));
echo '</strong><br />Author: '
echo stripslashes($row['area_code']);
echo '<br />ISBN: '
echo stripslashes($row['price_range']);
echo '<br />Price: '
echo stripslashes($row['saved_link']);
echo '</p>'
}

The above query prints the entire table and I would like a query that limits to the form choices indicated above.

View Replies !
PHP: MySQL UPDATE Query
I need to have a page where the user can update his info and/or delete his record. I haven't tested the DELETE query yet.

When I open the page it shows all the info stored in the database. When I change something and hit the update button I get the message that the record was successfully updated, but nothing really hapens.

If you want to see what's happening go to URL , click on the 'directory' link
The user ID is 'scooby', and password 'dooby'. If it does not work, try the following combination: user ID: 'sunny', password: 'trout' . Then click on the 'edit profile' link and try to change something and see what happens. I am attaching a php file of the 'edit profile' page, the one I am having trouble with so you can see the entire code.

View Replies !
Getting Variable From Mysql Query
what's the best way to set a variable = to a result from a mysql query?

View Replies !
Advanced Mysql Query
There are currently two queries in one of my scripts. One is:

SELECT * FROM foo

the other is:

SELECT var FROM bar WHERE something = 'somethingelse'

Is is possible to use a join statement and combine these two into one query? My reason is that I'm trying to speed up the script, and hopefully combining the queries will do that.

View Replies !
Mysql Date Query
I need to check if one script was run later than one hour ago - I had a problem with cron and want to put in a safety code.

On successful running of the script I remember the date in db
CREATE TABLE log(id INT NOT NULL auto_increment, ttime DATETIME, other_info TEXT, PRIMARY KEY(id));

The sql query that I use now is:
SELECT HOUR(CURDATE() - ttime) as h FROM log ORDER BY h LIMIT 1;

However I have a problem - it returns sometimes value NULL (which is always first).

If I use the following syntax:
SELECT HOUR(CURDATE() - ttime) as h FROM log WHERE h IS NOT NULL ORDER BY h LIMIT 1;

I get the error: Unknown column `h` in `where clause`. What can I do?

View Replies !
Mysql Query - Select Any
I have the following sql statemant to search a mysql database that gets
if values from a form with combo box's in.

SELECT * FROM hottubs, manufacturers WHERE manufacturers.manid =
hottubs.manid AND hottubs.type = '%s' AND hottubs.dimlength <= '%s' AND
hottubs.dimwidth <= '%s' AND hottubs.dimhight <= '%s' AND
hottubs.seatsto <= '%s' AND hottubs.shape = '%s' ORDER BY
$thesearchtype_search.

Everything works fine except I want to add a select "any" from the
shape combo box. I really need a way of cutting out the last " AND
hottubs.shape = '%s' " if the $_GET['shape'] = 'any'
Will this work using a variable as shown below??

IF ($_GET['shape'] != 'any' )
{
$shape = AND hottubs.shape = '%s'
}

SELECT * FROM hottubs, manufacturers WHERE manufacturers.manid =
hottubs.manid AND hottubs.type = '%s' AND hottubs.dimlength <= '%s' AND
hottubs.dimwidth <= '%s' AND hottubs.dimhight <= '%s' AND
hottubs.seatsto <= '%s' $shape ORDER BY $thesearchtype_search

I have only been doing php about a month so go gentle!

View Replies !
MySQL Query On The Same Page.
here it is: i have a table with lets say 2 fields, first_name and last_name. When user enters index.php he gets database records sort by first_name (ORDER BY first_name). Now i ave made two links above those records. They are: sortb by firts name and sort by last_name.

My question is, what code should be written for the link sort by last name if i wanna show the same records already displayed but sorted by last_name???

And how do i make that if user has clicked sort by last name that thislink is disabled (not underlined, just bold text) and if he clicks on sort by first name that this link becomes text.

View Replies !
MySQL Query With PHP Variables
My Query is like this I have two dates inter in by the user and set to $x(lower) and $z(higher). I want to pull all entries that are between these 2 dates.

This does not work (Why?):

$result = @mysql_query("SELECT id, maincourse, veggie, veggie2, fruit, bread, dessert, drink, DATE_FORMAT(day, '%a %b, %D') as date_string FROM $fromwhere WHERE day<=$x AND day<=$z");

note: "WHERE day>$x" does work.

View Replies !
Query Inconsistency (MySQL Vs PHP)
I have the following query:

select DATE_FORMAT(accountingdate,"%c") as month,sum(totalprice -
freightcost - insurancecost - vat2 - vat3 - vat4) as totalprice from
invoice where cancelled=0 and deliveryagentid=0 and (employeeid=0 or
employeeid=37 or employeeid=53 or employeeid=50) and
DATE_FORMAT(accountingdate,"%Y")="2005" group by month order by month;

Giving the following result in MySQL (correctly):
+--------+--------------+
| month | totalprice |
+--------+--------------+
| 1 | 540274351.00 |
| 10 | 119601657.00 |
| 11 | 118712994.00 |
| 12 | 109391926.00 |
| 2 | 112606305.00 |
| 3 | 99175084.00 |
| 4 | 101754796.00 |
| 5 | 120049120.00 |
| 6 | 138227787.00 |
| 7 | 166565653.00 |
| 8 | 136475650.00 |
| 9 | 133242379.00 |
+--------+--------------+

When I run the same query in PHP (on a web site, I get):

4 538068.00
4 538068.00
4 538068.00
4 538068.00
4 538068.00
4 538068.00
4 538068.00
4 538068.00
4 538068.00
4 538068.00
4 538068.00
4 538068.00

View Replies !
Mysql Search Query
Is there a way to search for a word in any of the fields of a row using simple sql for my sql?

I have a rather complex search function on my site and right now, I dump all the text of all fields (that are text fields) in a
special field. The search function then searches this "keyword" field.

Is there a smarter way of doing this.

To recoup

I have an mysql database with about 500 records, each containing over 20 text fields (address, name, etc.... etc....). I want the
user to be able to search for a particular word (e.g. fishing or rock climbing) in all records and all fields and I would like Mysql
to return the IDs of the fields that match.

Along the lines of

SELECT ID FROM TABLE WHERE * LIKE "%test%";

View Replies !
MySQL Query And Arrays
I have a 'links' category on Table A and I want to retrieve the links from the Table and display them in a list-like fashion when the page is called upon. How would I go about seperating the links from one another (there a space inbetween each link.. EXAMPLE: http://asdf.com http://asdasd.com http://asdfff.com), loading them into an array (or using the best possible method to acces them easily) and then displaying them in a list like fashion..?

View Replies !
Date/MySQL Query
I am making an event calendar that allows users to add events. An event can possibly span multiple days so I made two fields for start date and end date. This all works fine.

I want to be able to grab the data out of the database through a query and display it on the webpage in order of date. So I'm ordering by the start date. However if the event is 3 days long I want to show the event on the page 3 times, with all other events in between also show. I have not been able to figure out the logic on how to get the event to show up 3 times with other events in between them?

Sample Data:
Event 1 Dec 31 2002
Event 2 Dec 31 2002
Event 1 Jan 01 2002

View Replies !
Oddball MySQL Query
What I'm trying to do is take php variables i got from user input, and
pass them as the MySQL query terms.

$query = "select * from ident where ".$searchtype1."=".$searchterm1."";

ERROR: Invalid query: You have an error in your SQL syntax near '=' at
line 1

I have also tried,

$query = "select * from ident where ".$searchtype1." like
'%".$searchterm1."%'";

ERROR: Invalid query: You have an error in your SQL syntax near 'like
'%%'' at line 1

both return similar errors as you can see. I have o idea if the problem
lies with the variable (i try echo-ing, and printing them and i get
nothing) or if it actually is with my sql syntax (i enter the first query
above in mysql from the shell without variable obviously and it returns
the results perfectly). Here is the rest of my code and any help is
greatly appreciated.

Form for getting variables:

<form action="searchrsiident.php" method="post" align="center">
Choose Search Type:<br>
<select name="searchtype1">
<option value="NSN">NSN
<option value="NIIN">NIIN
<option value="NOMENCLATURE">NOMENCLATURE <option value="CAGE">CAGE
<option value="Field5">Field5
<option value="REV">REV
<option value="EQUIP">EQUIP
<option value="RSI_P/N">RSI_P/N
<option value="WAITING_IN">WAITING_IN <option value="NOTES">NOTES
<option value="SOS_CODE">SOS_CODE
<option value="WORK_ORDER">WORK_ORDER <option value="L_QUOTE">L_QUOTE
<option value="A_QTY">A_QTY
<option value="A_PRICE">A_PRICE
<option value="L_WO">L_WO
<option value="L_NOTE">L_NOTE
</select>
<br>
Enter value to search by:<br>
<input name="searchterm1" type=text>
<br>
<input type=submit value="Search">
</form>


Relevent part of my php code (i hope):

$searchtype1 = addslashes($searchtype1); $searchterm1 =
addslashes($searchterm1);

$db = mysql_connect("localhost", "browseuser", "");

if (!$db)
{
echo "Error: Could not connect to database. Please try again
later."; exit;
}
}
mysql_select_db("rsi_ident");
$query = "select * from ident where ".$searchtype1." like
'%".$searchterm1."%'";

$result = mysql_query($query, $db) or die("Invalid query:
".mysql_error()); $num_results = mysql_num_rows($result);

View Replies !
Layout Of MySQl Query
Only thing i cannot seem to
grasp yet is that !$column is the first, and then
you close it when it's not the first anymore.
To me this would seem like it would only give one collumn.

[Why didn't you quote the previous posts?]
[Yes, I know Google groups suck]

knoak wrote:[color=blue]
> Yes, that works great! Thanks a bunch!
> Too bad i don't understand this (yet) completely...[/color]

[previous posts pasted back in]
[color=blue]
> $result = mysql_query("SELECT * FROM datatable WHERE item=$searchterm
> ORDER BY item ASC",$db);[/color]

## start the table
echo '<table class="search_result" summary="search result">'

## initialize control variable
## $control will either be 0 or 1
## 0 means we're about to output the first column
## 1 means we're about to output the second column
$column = 0;

## for every record selected
while ($row = mysql_fetch_array($result)) {

## start a table row if it is the first column
if (!$column) echo '<tr>'
## print the data
echo '<td>', $row['whatever'], '</td>'
## end the row if it is not the first column
if ($column) echo '</tr>'

## swap between 1 and 0 every time this line executes
$column = !$column;
}

## if there were an odd number of records selected we will
## be left with an empty last cell -- fill it
if ($column) echo '<td>(empty cell)</td></tr>'

## end the table
echo '</table>'

View Replies !
Mysql Parameterised Query
I'm using mysql 4.1 and php5.0.4. Since (AFAIK) this version of mysql
supports parameterised queries, is there a way to accomplish that using
mysql_... functions (looks like mysql client library is unaware of this
feature), I need it to avoid sql injection in a "right" way... :))

View Replies !
Problem With Mysql Query
I'm experiencing a very strange problem with a MySQL query.

Firstly, I use mysql_query() to print the value that I need to modify
I modify it by doing an update ( mysql_query("UPDATE TABLE ...") ) .
When I look into the table directly (with phpmyadmin) the value has
been correctly changed.

But when I use again mysql_query() to print the new value,
it gives me the last value that were there, before the update.
I have to refresh the page ( F5 ) to get the correct result.

I have this problem only with IExplorer.
It works with Mozilla.

Somebody told me that maybe it was a problem of the cache of my
Explorer, but I didn't manage to find anything to make it work.

View Replies !
MySQL Query Tool For Php
I am making the jump from ASP/Access to PHP/MySQL.

And I really miss the ease of generating sql queries inherent in
access.

I've been reduced on occassion to modeling the database in access,
using access to generate the complex sql query then copying it over to
my php app.

Question: Is there a tool that interfaces to mysql and generates sql
queries?

View Replies !
Mysql Query Table
i got a problem with an multidimensional array out of a sql DB after each table print he should select the next line of $thismember but i don't know how to do. PHP Code:

View Replies !
Testing Mysql Query
Basically I am using PHP 5.1.2 with Apache 2.0.5 on a FreeBSD 5.4 box
with Mysql 4.1.1 running.

I am attempting to write information to a Mysql table called Jabber. I
can connect successfully, query data, and write data pretty much
without problem. My problem is this.

I am trying to do some duplicate checking on this table so I query the
dbase with the following:

/* Searching for username in Authreg database and assiging it to
variable */
$query1 = "SELECT * FROM `$table` WHERE username='$username'";
$query1_results = mysql_query($query1) or die("Query Failed");
$existing = mysql_result($query1_results, 0,0);

Problem is this.

When a user already exsits in database I have a conditional if
statement that looks like such:

/* Conditional statement that searches for exsiting username */
if ($username == $existing) {
die ("Please select a unique username");
} else {
....
}

And it errorr out telling me to, "Please select a unique username" as
stated above.

When I am adding a new user to the database above I get the following
error in my logs or in the browser depending on what --display-errors=
is set to in my php.ini.:

Warning: mysql_result() [function.mysql-result]: Unable to jump to row
0 on MySQL result index 4 in /usr/local/www/sfg/add_jabber/add_test.php
on line 38

I know this error is happening as a result of the following line when
the user is not present in the database:

$existing = mysql_result($query1_results, 0,0);

View Replies !
Phpcoin And Mysql Query
This maybe off-topic as it is mainly SQL, but I thought I would ask here
as I have had many helpful replies from here in the past and also the
query is being run from a php script (although examples here are from
where I was testing it in phpMyAdmin)
I'm using a piece of software called 'phpcoin' along with the popular
'IPN' mod. I am having some problem with it and have got it down to an
mySQL function functioning incorrectly.

This is the structure of the tables involved:

phpcoin_clients:
Field Type Null Default
cl_id int(11) No 0
cl_join_ts varchar(10) Yes NULL
cl_status varchar(20) No pending
cl_company varchar(50) No
cl_name_first varchar(20) No
cl_name_last varchar(20) No
cl_addr_01 varchar(50) No
cl_addr_02 varchar(50) No
cl_city varchar(50) No
cl_state_prov varchar(50) No
cl_country varchar(50) No
cl_zip_code varchar(12) No
cl_phone varchar(20) No
cl_email varchar(50) No
cl_user_name varchar(20) No
cl_user_pword varchar(50) No
cl_notes text No
cl_groups int(11) No 0

phpcoin_clients_contacts:
Field Type Null Default
contacts_id int(11) No
contacts_cl_id int(11) No 0
contacts_name_first varchar(20) No
contacts_name_last varchar(20) No
contacts_email varchar(50) No

The sql query is as follows:

SELECT cl_id from phpcoin_clients, phpcoin_clients_contacts
WHERE (cl_email='email@domain.com')
OR (contacts_email='email@domain.com')
AND contacts_cl_id=cl_id

View Replies !
MySQL Workaround Query ?
How is it possible to work around a security issue with an Apache server
running phpSuExec and which doesn't allow the creation of arbrirary
MySQL username logins ?

I'd have thought that most 'payment & services' sites would use the
following sytem and all referencing a MySQL database to check details;

1) Details input by user first time.
2) Upon return, input login name and password.
3) Click on button for number of days (rerouting to PayPal,WorldPay or
whoever) for services.

I am informed that it is possible to access the cPanel by using a cPanel
script but I can't find script examples anywhere.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved