An OR In The Mysql WHERE Syntax
I have this right now:
SELECT title, COUNT(*) as numissues FROM comics WHERE type ='Comic Book' GROUP BY title"
But I need something like:
SELECT title, COUNT(*) as numissues FROM comics WHERE type ='Comic Book OR IS NULL' GROUP BY title"
The second line doesn't work. How would I get it to select where IS NULL and also Comic Book?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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:
Mysql Syntax
sorry to cross post this, but i know most of you at least dabble with mysql, and this forum seems a bit more active than the mysql one so here goes... This is what i'm trying to do..... IF EXISTS (tablename) #update some fields ELSE CREATE TABLE tablename( #fields ); INSERT INTO tablename all the values i need. Seems straight forward, but can't figure it out Tried every permutation of IF TABLE EXISTS and also tried IF EXISTS (SELECT * FROM tablename) but they both give errors. Thanx for any help with this one, it's driving me nuts.
Mysql Syntax?
What would be the syntax of a mysql query when I want to pull the id and another specific column in a row. example: $sql = 'SELECT * FROM products WHERE id = '.$id.', boy = '.$_POST["boyGirl"]; right now I get this error: 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 ' boy =' at line 1 SQL: SELECT * FROM products WHERE id = 5, boy = in /home/realfina/public_html/thediaperbakery/inc/mysql.class.php on line 107
Mysql / PHP : Syntax Error
for php syntax when i call Mysql database I have wrote that and my sql connection is working I just have a problem with this command line : $query = "SELECT * FROM utilisateurs WHERE pseudo_utilisateur='$login'"; $acces = mysql_query($query);
Mysql UPDATE Syntax
what is wrong with this code? It generates no erros, but doesn't work either: $query = "UPDATE $usertable SET dl=dl+1 WHERE id=$id"; $result = MYSQL_QUERY($query); There is a unique id number for every row in my table. There is also a column called "dl" which holds the number of downloads certain files have gotten. I'm trying this code on my download page so that every time someone downloads a file (identified by its id number) the "dl" column for that file is incremented.
Mysql JOIN Syntax
I am trying to JOIN two tables together using the common column "Username". My code is ECHOing all of rows of column "title". I want to just ECHO the column "title" rows that are specific to the "Username". example: I have a user named "ballhogjoni". This username is stored in a table named 'users' and in a table named 'products' under the column "Username". There is a "Username" column in each table. Code:
Mysql Syntax Error
what is wrong with this statemnet: $query = 'SELECT * FROM products WHERE id = '.$id.' AND boy = '.$boyGirl.' OR girl = '.$boyGirl; what do i do to fix it?
PHP MYSQL Insert Syntax
$q = "INSERT INTO downloads (sub, title, name, email, link, date, description, pic) VALUES ('$c', '$t', '$n', '$e', '$l', 'NOW()', '$d', 'NULL')"; $addinfo = mysql_query($q); Does that look right? I don't have many resources for php and mysql.
Mysql Update/replace Syntax
To keep track of how many fruits my visitors buy, I use a mySQL database (2 columns: "fruit" and "quantity")....so can we make these following mySQL queries work somehow? (visitor buys 5 apples): replace into fruit_database set fruit = 'apple' , quantity = quantity + 5; (visitor buys 7 apples): replace into fruit_database set fruit = 'apple' , quantity = quantity + 7; (visitor buys 1 grape): replace into fruit_database set fruit = 'grape' , quantity = quantity +
Query Syntax In MySQL Does Not Work In PHP Code
I have a syntax issue. I produced a query in MyCC that pulled the data from a MySQL table perfectly the way I wanted, but when I put it into my webpage code in PHP the syntax of having a beginning quotation mark causes the value quotation marks (in red) to not group properly. The query pivots the data in one column so that the data creates one column for each of the corresponding values in the first column. (With help from the MySQL Wizard tutorial). Here is the code the way it should be: PHP Code:
Php - Update Mysql Database - Syntax Error
When i try and update the database table i get this error. 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 'desc='My name is ***** and I'm a 17-yr. old junior. I play electric ba' at line 1 what i am doing is having the user fill in a large text area and saving it to a database. So i think the problem could possibly be that they are using ' and " in textarea to mess it up? Code:
MYSQL CASE Statement Within PHP Syntax Or Correct Quoting ?
I'm trying to use a MySQL "CASE" statement within PHP to develop a conditional query. The query runs fine within from the MySQL command prompt with the "case" statements. And the PHP code works fine when I remove the lines that begin with "case". However when I run the query as listed below within my PHP code i get the following: [Fri Apr 20 22:15:24 2007] [error] [client 10.188.50.74] PHP Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /srv/www/htdocs/mysql-learn/acetrack-post.php on line 68, referer: http://webserver1/mysql-learn/acetrack-post.html < code snip > $query =" SELECT acetitle, tracking_no, aceamt, case when (To_days(curdate()) - To_days(create_date)) >= 90 Then pototalamt else "" end as "90past" , case when (To_days(curdate()) - To_days(create_date)) < 90 and (To_days(curdate()) - To_days(create_date)) > 30 Then pototalamt else "" end as "30-90past" FROM Purtable t LEFT JOIN acelog a ON ace=acenum WHERE ace='0220' GROUP by po ASC "; $result = mysql_query($query); < /code snip > Thanks in advance for any help.
Help With Do While Syntax
I need to know how to run a piece of code depending on two conditions. Just need the correct syntax. Something like: do { # get database results code } # then the while... can't get the syntax right while (($row = mysql_fetch_array($result)) && ($row["Status"] == $num)); } else { echo "Sorry, no records were found!"; }
If Else Syntax
In my header I have $SQL_QUERY which has the SQL Select Query then a $GET_QUERY_RESULTS which runs the query on the database. I need code to perform the following: IF $GET_QUERY_RESULTS returns values, THEN print ("I will be printing these results in a table, with one table header, and rows that are repeated based on the number of results") ELSE I don't want anything printed or I will say "No results found." I know the code to print it all, but I'm not sure how to put it all with the if else statement.
Syntax
I have an int field in a database and for teh purposes of this case the insert statement doesn't insert anything into the field using the ' ' syntax however in the mysql database this appears as 0. I was wondering can I still use the empty syntax as follows or will it not work as it is 0 does is this not classed as empty? if (empty($row['intTest'])){ $sns= "empty"; }
Pattern Syntax
is there a not operator in the pattern syntax thingy? e.g. (*+) all characters but i want to exclude [ and ]
Heredocs Syntax
In order to enable global includes...I have been toying around with heredocs syntax. The code; /* include1.php */ <?php $html = <<<END <html> <head> <title>Sportsmen Afield| >Zarahost/index1.php <?php echo($title); ?></title> </head> END; ?> <?php $body = <<<END <body> echo Hello World END; ?> <?php $footer = <<<END Copyright © 1998-2002 - Mysite.Com/Mysitename All Rights Reserved - <a href="mailto:info@sportsmenafield.com"style="color:beige">Webmaster</a> </body></html> END; ?> /* index1.php */ <?php include("include1.php"); echo $html; echo $body; ?> Hello World <? echo $footer; ?> ------------ This does not work... and I haven't found the culprit. Here is the browser content which contains an error message: Parse error: parse error, unexpected T_SL in /home/httpd/vhosts/sportsmenafield.com/httpdocs/xarahost/include1.php on line 13 Hello World Here is the 'Source code in the browser: <br /> <b>Parse error</b>: parse error, unexpected T_SL in <b>/home/httpd/vhosts/sportsmenafield.com/httpdocs/xarahost/include1.php</b> on line <b>13</b><br /> Hello World
Heredoc Syntax
Is there a way to call a PHP function from within a heredoc passage? I experimented with this a bit, and did not meet with success. For example, if I have a long section of HTML that I want to place several PHP variables in, but I want to use a function on the variable, like htmlentities() or something.
RFC Definition Syntax
Can anyone tell me where the RFC definition syntax is documented? I am referring to such things as the use of <...>, [...], 1*, etc. I find this sort of thing in the RFC's for POP3, MIME, etc.
Syntax Problem
I have the following PHP/MySQL code segment $query2="UPDATE reports SET fsacars_rep_url = $url_new WHERE pilot_id = $pid"; echo"$query2"; $result2=mysql_query($query2) or die(mysql_error()); The above code produces the following messages: The echo of the query shows: UPDATE reports SET fsacars_rep_url = http://69.72.192.154/ ~caa/caa/logbooks/no_rept.txt WHERE pilot_id = 2 When the query runs the following error message is generated: 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 '://69.72.192.154/~caa/caa/logbooks/no_rept.txt WHERE pilot_id = 2' at line 2 What is the proper syntax?
Syntax Error
Is it possible to use both Where and Order by in the same statement. Im pretty sure you can but i cant seem to get hte syntax right. Bewlos is the line im refering to: $qry = "SELECT * FROM `$table` order by `$_GET[sortby]` desc limit $StartFrom, $Limit" WHERE `username` = "'.$session->username.'"'
Syntax To Change Value
I am trying to change a value but cant quite grasp the syntax <? $vtfa=test $dn=1 ?> <td><?= $vtfa.$dn ?></td> <? $dn = $dn + 1 ?> <td><?= $vtfa.$dn ?></td> <? $dn = $dn + 1 ?> <td><?= $vtfa.$dn ?></td> What I want are the three cells to consist of test1, test2 and test3. As you Any help appreciated
Path Syntax
I know that a dot (".") stands for the current directory, two dots ("..") stand for the parent directory, but could someone please explain to me what ".:" stands for?
Syntax Not Allowed
The following is not allowed (simplified for this forum): but it seems reasonable to me. Could some one explain mw lack of insight? $t = (array(1=>"Sold", 3=>"Transit"))[$location_id]; Parse error: parse error, unexpected '[' in /var/www/html/GEM-is/batchJobs/sales.php on line 183
Case Syntax
I've no Mysql NG access from my ISP, so let me ask here. I've a case statement in mysql. Here is the code: select ...., case myvalue when 'X' then valueX when 'Y' then valueY when 'A' then valueY when 'B' then valueY In my case, Y,A and B gave the same value. I'm trying to do something like: case myvalue when 'X' then valueX when in('Y','A','B') then valueY But I can't get it to work with IN statement. What's the syntax ?
Different Syntax Mysql_query
Sometimes I see this piece of code $result = @mysql_query( $query ) or $result = mysql_query( $query ) What is the use of the '@' character ?
Syntax Error?
Why does the following line create a Syntax error in PHP. $Mac = ( (strstr($query,'Mac') || (strstr($query,'Mc') || (strstr($query,'M ') );
Syntax - If Else Statement
Have a little code that isn't working for me: if ( $requestor == "requestor1" ){ $autoresponse = "emailaddress1";} else ( $requestor == "requestor2" ){ $autoresponse = "emailaddress2";} Where is the syntax wrong? Getting a parsing error... I was having trouble finding docs that showed syntax for defining variables through ifelse statements.
Preg_match_all Syntax
I'm trying to put together the syntax for a preg_match_all(), at the moment I have the following. PHP Code:
Object Syntax
I keep seeing this syntax come up when working with classes, but I have yet to notice an explanation of the following type of syntax: PHP Code:
PHP Manual Syntax
I have another trivial question. In the PHP manual, the description section often contains the following elements: Description array mysql_fetch_array ( resource $result [, int $result_type] ) I am wondering what is a ( resource $result [, int $result_type] )? What is a result $result and why the [,int $result_type])
Array_multisort Syntax
I have a table loaded in an array like so : $table[0][ID] $table[0][text] $table[0][text2] $table[1][ID] $table[1][text] $table[1][text2] $table[2][ID] $table[2][text] $table[2][text2] ...... now I want to sort this table using the ID column.
Update Syntax
mysql_query("UPDATE scfmforening SET scfmpad=$scfmpad, scfmpnm=$scfmpnm, scfmort=$scfmort, scfmwww=$scfmwww, scfmwww=$scfmwww, scfmept=$scfmept, scfmkom=$scfmkom WHERE scfmnum=$scfchknum ");
DELETE Syntax
i have this code: $sql = "DELETE FROM $table_name WHERE subscribeid = $userid"; it works fine, but i also want to check some other variables when i delete. i want to use: subscribemail = $usermail subscribecode = $usercode i tried: $sql = "DELETE FROM $table_name WHERE subscribeid = $userid AND subscribemail = $usermail AND subscribecode = $usercode"; but it doesnt work. i looked in the manual but couldnt see what i was doing wrong, anyone got any ideas?
Coloring Various Syntax
I've searched on google for PHP scripts coloring syntax e.g. asm, c, c++, bash etc. I've only found some CGI, apps, modules for Apache - but i can't use them on my server (due to my restricted permissions - i can use only PHP and MySQL). Are there any PHP scripts for coloring syntax?
Similar_text() Syntax
i'm having a go at coding a simple, quick-n-dirty searchengine, which involves the similar_text() function. However, I can't seem to get it to calculate the percent-wise similarity between two variables. The manual states that to the syntax: int similar_text(string first, string second, double [percent]); adding the third argument as a 'reference' (what's that?) will calculate the similarity in percent. How would I get that value?
Syntax Error ???
on login.php , we can see that : (...) $sql = "SELECT Login FROM logins WHERE Login='$fusername'"; $result = mysql_query($sql) or die("Couldn't execute query1."); (...) field : login from table: logins fusername is a valid form field. I just can't understand why I get the message Couldn't execute query1. I don't see any syntax error. :-(
SQL Syntax Error
Where is the error? mysql_query("INSERT INTO list (status) VALUES ('$status') WHERE name = $name")or die(mysql_error());
How Can I Escape The XML Syntax
i have a textarea where users can input information about themselves. They can even edit the texts (making the texts bold, italic...). It works fine when i try to add the info into the db. But when i try to display the info from the db, it displays some characters like \" whatever. I used stripslashes, but it didn't solve the problem. What do you advise me so that i can handle the XML special characters not to disturb my design??
Error In Your Sql Syntax
Could not run query: 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 'character WHERE name = 'Chris" at line 1 Im getting this error with this code. I think the problem is... 'Chris" (part in bold), but I can't fix it. Code below where error occures. $result = mysql_query("SELECT guid FROM character WHERE name = '".$user."'");
Write My Own Syntax
Is there anyway to write my own syntax, like i could put like 5 syntax in 1 so all i would have to date is like mysyntax(' '); ?
Convert Old PHP Syntax To New
I'm attempting to convert old PHP syntax to the new PHP syntax. Previously this form worked like a charm, though now, it does nothing exciting at all. Could you give me guidance as to how I might address some issues; 1 - I understand that variables from a POST method are now prefixed with $_POST (I've attempted to use this below). Is this usage correct? 2 - I'm not sure how to call/reference the variables created from the mySQL query - Is it $_SERVER? 3 - And now I've created new variables to check password, and user existance, should these be prefixed $_POST also? Code:
PHP 4 To 5 Short Tag/syntax
I'm trying to convert a PHP 4 script to PHP 5... but have come across a short tag which i'm not quite sure how to re-write in PHP 5 - with short tags disabled. The PHP 4 short tag is: <?= Now I want to convert that to PHP 5... I assumed that the correct way to do that in PHP 5 would be to do the following: <?php echo But that only seems to do what was intended for some of the functions of the PHP script... e.g. it doesn't seem to work for: <?=iif($_type=="today", $_SUPP["language"]["dashtoday"], $_SUPP["language"]["dashnewstitle"])?> I would much appreciate it if someone would enlighten me as to what the correct php 5 tag would be - with short tags disabled.
Array Syntax
First I define an array and assign 65 values to it from a mysql database. Using print_r (array_values($arr_anmref)) I can see all the values and they are correct so no problem there. I then need to process the information from a form when the users clicks ok. (This is to update the records based on if the user has checked or unchecked a checkbox). When the user presses the OK button they are taken to a new page where I want to process the form and show the results of the processed information. However in the code I need to use the values from the array but its misfiring. The array is now empty and print_r (array_values($arr_anmref)) .....shows nothing I have tried adding session_start() at the top of both pages but to no avail.
Array Quote Syntax Help
what's the correct syntax for the $_POST elements? do I single quote the array keys? $pdf_data = array( 'first_name' => '$_POST[first_name]' , 'last_name' => '$_POST[last_name]' , 'department' => '$_POST[department]' , 'phone_extension' => '$_POST[phone_extension]' );
Pattern Syntax Help Needed
I am trying to insert an astrisk (*) in front of a particular Selection field in an HTML file. The purpose of this would be to mark fields that have missing or incorrect data from a form post. But alas, I am having trouble getting the pattern syntax right. This is what I have so far:
Correct Date Syntax?
I have a mysql DATE column called date_available that I'm attempting to make this happen:
|