php,mysql,arrays,error-handlingRelated issues-Collection of common programming errors
Milen A. Radev
php postgresql
I am a complete novice at php and postgres. I have been searching all over the net for an answer but no joy! I have a postgres table called workorders. It has a primary key (ident). I am trying to up date it using a php script/program. Basically the ident is the workorder number. I have written a php script where i type in the workorder number, post it to another php file, which connects to the database, finds the ident that matches and updates it by adding ‘paid’ to a column called paid. I have
hsalimi
java php ruby django email
I am using django. I just want to know is it possible to check if an email is a correct one, so that it will be definitely delivered (99.99%)? If the user entered an email like [email protected], it is technically a valid email but does not exist really. Can I detect such emails?
MikeB
php zend-framework zend-navigation
I’m just not getting this; I’m using a standard XML-based Zend_Navigation impl, right out the box so-to-speak – and every page seems to have every menu option. I’ve tried everything – activeOnly, renderSubMenu, renderParent but they all return my either everything or nothing. I’m assuming I’m misunderstanding, because what I want (the items in the “home” node to be visible on the “home” page etc) seems to be what I would have considered the default behaviour. If I have to start setting content
kdevs3
php
In localhost (using Wamp on windows). I’m trying to use this:<? $xml = simplexml_load_file(‘http://stocklamp.tumblr.com/api/read/xml’); $posts = $xml->xpath(“/tumblr/posts/post[@type=’regular’]”); foreach($posts as $post) {?> <?echo $post[‘id’];?> <?echo $post[‘url-with-slug’];?>”> <?echo $post->{‘regular-title’};?> <?echo $post->{‘regular-body’};?> <?echo date(“jS D M, H:i”,strtotime($post[‘date’]));?> <?}?>When trying, all I see is this o
Yogus
php odbc derby
I installed easysoft odbc derby driver in windows 7 and try to connect to derby database after I configure on ODBC Data Source Administrator DSN and connection succeed.then i tried on php script//commz is the DSN name ind ODBC data source admin $connection = odbc_connect(“commz”,$user, $password);if ($result = odbc_exec($connection, “SELECT * FROM ADDRESSBOOK”))print “Command executed successfully<BR><BR>”; elseprint “Error while executing command<BR><BR>”;// Print resul
Cool Hand Luke UK
php mysql date-format
Hi I have looked at a question already posted about this and tried to adapt my code to do a simlar thing. Basicly I have a field in my mysql database that has the date in this format yyyy-dd-mm i need to the format to be dd-mm-yyyy. Currently my code is getting stuck on the line echo “<td><strong> (“d/m/y”,”. $row[‘date’] .”)</strong></td>”; and reads this Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’. Not sure how to fix this any ideas I would be g
Staunton Allen
php mysql
I’m trying to create my own query form, so that I can create a table in my DB, update data, select data, and so on. I have a file test.php with the form on which I will type my commands in a textarea. It will send my query to submitquery.php which contains the exact following:<?php $con=mysqli_connect(“host”,”user”,”pass”,”my_db”); // Check connection if (mysqli_connect_errno()){echo “Failed to connect to MySQL: ” . mysqli_connect_error();}$result = mysqli_query($con,”$_POST[‘myquery’]”);mysq
sohanmax02
php html
I made some changes in a website. The website was initial static and to make some changes I changed the links of the website to .php.I made the changes and it was working perfectly fine in localhost. I saw no errors and no warnings.However when I moved it to a live server I saw this problem.Server error The website encountered an error while retrieving http://prakashchhetri.com.np/projects/hmaloha/. It may be down for maintenance or configured incorrectly. Here are some suggestions: Reload this
andy
php sprintf
I am new to PHP and I am somewhat understanding it. Now I am working on something but I keep getting a error message saying Parse error: parse error, unexpected T_ECHO in C:\wamp\www\mymoney.php on line 11. Now I am looking at line 11 and I don’t see anything i am doing wrong. So I was woundering if someone can help me understand what I might be doing wrong thanks.<html> <head> <title>money $</title> </head> <body> <?php $balance=55.75; $newShirtCost=15.75;
Remco Overdijk
php linux amazon-web-services postfix php-mail
I’ve followed the directions on this page to setup mail() on AWS linux ubuntu, but the mail function is not working. I know I’ve written the send mail script correctly, so is there something else I need in order for this to work? Is there a special webmail software or something I need?EDIT:display_errors is on. PHP code is as follows. Success message is displayed, but the email is never received.$to = “[email protected]”; $subject = “Hi!”; $body = “Hi,\n\nHow are you?”;if (mail($to, $subject, $b
Cool Hand Luke UK
php mysql date-format
Hi I have looked at a question already posted about this and tried to adapt my code to do a simlar thing. Basicly I have a field in my mysql database that has the date in this format yyyy-dd-mm i need to the format to be dd-mm-yyyy. Currently my code is getting stuck on the line echo “<td><strong> (“d/m/y”,”. $row[‘date’] .”)</strong></td>”; and reads this Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’. Not sure how to fix this any ideas I would be g
Staunton Allen
php mysql
I’m trying to create my own query form, so that I can create a table in my DB, update data, select data, and so on. I have a file test.php with the form on which I will type my commands in a textarea. It will send my query to submitquery.php which contains the exact following:<?php $con=mysqli_connect(“host”,”user”,”pass”,”my_db”); // Check connection if (mysqli_connect_errno()){echo “Failed to connect to MySQL: ” . mysqli_connect_error();}$result = mysqli_query($con,”$_POST[‘myquery’]”);mysq
AFrieze
mysql concurrency entity-framework-4.1 ef-code-first
I am using Entity FrameWork 4.1 With the MySQL database and the MySQL connector 6.4.3 with a code first approach.Currently, I am attempting to configure concurrency with a timestamp field. The following is the code within my model object:[Timestamp] [DatabaseGenerated(DatabaseGeneratedOption.Computed)] [Column(TypeName = “timestamp”)] public DateTime RowVersion { get; set; }When I generate the database the RowVersion field is created with the proper trigger to update itself when the row is modi
Arjan Tijms
java mysql netbeans java-ee ejb
Hey I made an EJB program and I created entity classes form my SQL database. Everything worked fine and it can connect to my database, but I get this error now for some reason. Im using glassfish v3 and netbeans ide 6.8WARNING: Can not find resource bundle for this logger. class name that failed: com.sun.gjc.common.DataSourceObjectBuilder SEVERE: jdbc.exc_cnfe_ds java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSourcemore random errors here.WARNING: RAR5038:Unexpected ex
TimWolla
php mysql
I would like to edit the old values in a table$row=mysql_fetch_row($res); //get two values in a row from mysql$value is obtain from $_GET[‘value’] and is used in the following form<form action=”renew.php?value=’.$value.'” method=”POST”>Enter your value: <br/><input type=”text” name=”firstvalue” size=”30″ value=”‘.$row[0].'”/><br/>Enter another value:<br/><textarea name=”secondvalue” col=”10″>’.$row[1].'</textarea><br/><input type=”submit” value
Natalie Webb
php mysql pagination paging
Hi I am trying to display my users data over pagesHere is my code://Run a query to select all the data from the users table $perpage = 2; $result = mysql_query(“SELECT * FROM users LIMIT $perpage”);It does display this the only two per page but I was wondering how you get page numbers at the bottom that link to your data here is my updated code$result = mysql_query(“SELECT * FROM users”); // Let’s get the query $nrResults=mysql_num_rows($result); // Count the results if (($nrResults%$lim
user unknown
mysql sql database performance
So, I have a database with 5 million records and it stores the information for a question and answer site. The structure is…question, qid, quserid, answer, auserid;(qid is the id number for the question)I’m trying to find all the users that have questions NOT answered by a particular user and sorting it by the amount of questions that weren’t answered by a particular user. Here’s my query:SELECT quserid, COUNT(quserid) FROM `qanda` WHERE qid NOT IN (SELECT qid FROM `qanda` WHERE auserid=’myus
Philip Tiong
php mysql database sql-insert
trying to input code into the sqldatabase…what am i missing in here? Parse error: syntax error, unexpected T_OBJECT_OPERATOR<?php $name = “”; $email = “”; $msg_to_user = “”; if ($_POST[‘name’] != “”) {require_once(“storescripts/connect_to_mysqli.php”);// Be sure to filter this data to deter SQL injection, filter before querying database$name = $_POST[‘name’];$email = $_POST[’email’];$sqlCommand = “SELECT * FROM newsletter WHERE email=’$email'”;$sql = mysqli_query($myConnection,$sqlCommand);
Ed Cottrell
php mysql database
Here is my database connection code, whenever i sign up in form it always says “syntax error, unexpected T_STRING in”<?php//Database Connection Settingsmysql_connect(“localhost”, “root”, “”);mysql_select_db(“project mix”);global $connection;$connection = @mysql_connect(“”) or die(‘Connection could not be made to the SQL Server. Please report this system error at <font color=”blue”>[email protected]</font>’);@mysql_select_db(project mix,$connection) or die(‘Connec
Sly
mysql perl character-encoding https lwp-useragent
I’ve migrated to a new hosting provider, with same freebsd system, and one of my perl scripts stopped working properly.It downloads data from external https site and stores it in mysql db. Data is in cp1251 encoding, same encoding is in mysql base, tables and connection. From my.cnf:character-set-server=cp1251 collation-server=cp1251_general_ci init-connect=”SET NAMES cp1251″When connecting to mysql from perl script:$dbh->do(‘SET CHARACTER SET cp1251’);So, I’m getting this data with $ua = new
aolas
arrays xna streamreader text-files
right now, I’m going to make a scoreboard for my game. the program will displayed data from text file.in the program, I have arrays of string for player name and score.this is my streamreader code look like :public void ReadHighScores(){try{using (StreamReader sr = new StreamReader(“highscore.txt”)){string line;while ((line = sr.ReadLine()) != null){string[] parts = line.Split(‘,’);for (int i = 0; i < 5; i++){highScores.PlayerName[i] = parts[0];highScores.Score[i] = parts[1];}}}}catch (FileNo
doctordoder
objective-c arrays xcode pointers opengl
Following this thread, I saw an alternative way to initialize the values of an array which works for my situation. I can’t use the standard float *simpleArray = {1.0f, 2.0f} because this array needs to be have global scope, and it also needs to be initialized after several variables that can’t be initialized at the global-level (object pointers). I tried implementing one method from the thread like this on a simpler example which doesn’t involve a second array.float *simpleArray = malloc(_numVer
JohnP
php arrays class constructor global
My aim is to retrieve some data from a global array which is defined in another PHP file. My code is running inside “database.php” file and the array I want to use is inside “config.php” file.My code is as below:config.php$CONFIG = array(); // … $CONFIG[“DATABASE”] = array(); $CONFIG[“DATABASE”][“USERNAME”] = “user”; $CONFIG[“DATABASE”][“PASSWORD”] = “pass”; $CONFIG[“DATABASE”][“HOSTNAME”] = “127.0.0.1”; $CONFIG[“DATABASE”][“DATABASE”] = “my_db”; // …database.phprequire(‘config.php’);class D
Paul Manta
c++ arrays foreach c++11
In C++11 you can use a range-based for, which acts as the foreach of other languages. It works even with plain C arrays:int numbers[] = { 1, 2, 3, 4, 5 }; for (int& n : numbers) {n *= 2; }How does it know when to stop? Does it only work with static arrays that have been declared in the same scope the for is used in? How would you use this for with dynamic arrays?
Liath
c# asp.net arrays string
The below code writes a list of chocolate to a CSV file:using (StreamWriter outfile = new StreamWriter(@”C:\Users\Martin\Desktop\chocListWRITE.csv”, true)) //true: append text to a file with StreamWriter. The file is not erased, but just reopened and new text is added to the end. {Chocolate _choc = new Chocolate();string line = _choc.Serialize();outfile.WriteLine(line);Console.WriteLine(line); }in the console they are displayed as:11111, Mars22222, Bounty33333, SnickesBut in the output CSV fil
aks
javascript arrays node.js mongoose
I am making an application with Node.js, Express, MongoDB, Mongoose, and Passport.js. In my application users can write and store poems. I want to update the user when they delete a poem by removing the ID of the deleted poem from the “poems” field of the user document which is an Array of poem IDs. I’ve tried every permutation of the document.update call I can imagine, with and without a callback and none of them successfully remove the ID from the array.Here is my code now:exports.Delete = fun
hakre
php arrays
being new to php i am not ble to figure out how to use if else inside php array. i tried to do something like thisfunction column_title($item){$status=false;if($item->uTestimonials_approval ==’0′)$status=false;else$status=true;//Build row actions$actions = array($status ? ‘unapprove’ => sprintf(‘<a href=”?page=%s&action=%s&id=%s”>Unapprove</a>’,$_REQUEST[‘page’],’unapprove’,$item-> uTestimonials_id),:’approve1′ => sprintf(‘<a href=”?page=%s&action
user3093729
arrays string powershell integer addition
I have always been able to find what I have been looking for on stack overflow with the search function. However this time I am a bit stuck and though I would break out and ask the community.I am trying to write to a file with data from two arrays, for example:$arrayString = @(“User1?, “User2?, “User3?) $arrayInteger = @(1, 2, 3)The line that I am not sure of is the line to write this to a file I have tried the following:Add-Content $filePath$ ($arrayString[0] $arrayinteger[0])When I do this I g
dythe
android arrays listview filter
I am trying to get my listview to work with an searchbox to filter out installed applications that are in a listview. I have tried various methods such as overriding the toString() method and overriding the getFilter() method but none of them seems to work.Main Activity:public class AllApplicationsActivity extends Activity {private ListView mListAppInfo;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);// set layout for the main screensetContentView(R.l
Juxtapose Singh
arrays linux unix ksh
i’m a newbie to shell coding. My intention is to accept arguments from the command line, in CSV format, parse the input into an array. Something like,sh scriptname.sh 123,345,456,789…123,345,456..should be stored into an array. So far, i have acheived the following,#!/bin/ksh #get the argument to be parsed RID=$1 #Parse the argument, remove the space and store into and variable str=`echo $RID | sed ‘s/,/\ /g’ #Assign the value to a variable set -A RIDS $str #Get the count of arguments in the
Tepken Vannkorn
php validation mvc error-handling
Lets say I have a basic HTML form for sending e-mail:<form action=”contactSubmit” method=”POST”><label for=”name” class=”italic”>Name:</label><input type=”text” name=”name” value=”” maxlength=”20″ required=”required” autofocus=”autofocus” /><label for=”email” class=”italic”>E-mail:</label><input type=”email” name=”reply_to” value=”” maxlength=”255″ required=”required” /><label for=”comments” class=”italic”>Comments:</label><textarea name=”
Benjamin Netter
node.js error-handling express
I’ve been struggling for the past hours trying to find a decent tutorial on how to handle errors for a NodeJS + ExpressJS 3 api.I’ve read a lot of questions/answers on SO and read the official ExpressJS guide and still cannot figure out the proper way to do such an important thing. Most of the answers I found were relevant in Express 1 or Express 2, but are not anymore and the ExpressJS Guide just describes something out of context, which makes it really hard to understand.So here’s my use case
user2657462
c# list oop error-handling
I have the following code:List<int> moneys = new List<int>();Console.WriteLine(“Please enter the cost of your choice”);int money = int.Parse(Console.ReadLine());moneys.Add(money);From this if you enter text then the program stops working and an Unhandled exception message appears. I was wondering how you would handle the exception, if it is even possible so that the program doesn’t stop working?
TIMEX
exception error-handling conditional
I’m building a social networking website. I’m the only coder on it. Right now, Im’ the only one touching the code.Assuming I know what the users’ will input into the website, I catch them all with IF ELSE…do I really need try/excepts?I went through my code and realize that I have almost 0 try/except blocks…because I catch all the cases with IF/ELSE…However, I do log every error (and sends me an email when there’s an error, which never happens)I’ve done a lot of user testing and can’t find
John Smith
vba ms-access error-handling
I have a piece of code that reads information from a table and inserts it into a table with a primary key. The first table is user entered by many different people and the second is the table i wish to clean upTo give you an idea of what happens the pseudo code below should helpRecord is read into an array Record is then inserted into a table with a primary key on a unique identifier from the array If the unique identifier already exists in the table an error is thrown by the database (Not an Ac
LazyOne
zend-framework .htaccess redirect error-handling
I developed a website using Zend Framework. In order to handle errors, I want to add to the htaccess file the following lines so I can redirect the user to the corresponding every time there is an error.ErrorDocument 500 /errors/500.html ErrorDocument 404 /errors/404.html ErrorDocument 403 /errors/403.htmlso my htaccess file now in the /public folder looks like this:RewriteEngine on # Rewrite rules for Zend FrameworkRewriteCond %{REQUEST_FILENAME} !-f RewriteRule .* index.php# Security: Don’t al
TerryB
.net wcf web-services error-handling xml-validation
I’ve been asked to implement a webservice using WCF that will return a single standard response object that indicates whether the webservice call succeeds or fails and an error message if one occurs. It looks to me like this is not how WCF is intended to be used, is that correct? My problem is that I am using IDispatchMessageInspector.AfterReceiveRequest() to validate the request against an XSD prior to WCF deserializing it and calling my operation.If it fails validation how do I return my stand
Yarik
vb6 error-handling
I have some code with various “On Error Goto” error handlers in a few places to handle some broken third party hardware. I was getting an overflow error (read from the Err variable) in a routine that doesn’t have an error trap but is called by a routine that does. I always thought error traps were only valid in the routine they were declared, but it looks like an error in a subroutine can cause it to go to the calling function’s error trap. So I turned off the calling function’s error trap an
Line
php error-handling tags
I’m trying to turn on error reporting in my code. My PHP version is 5.3.6.I see error notice when I’m using following code:<?php error_reporting(E_ALL); ini_set(‘display_errors’,’On’); sample_error ?>even after comment line 2,error_reporting(E_ALL);but when I remove closing tag, I can see only blank page.I don’t want to begin again holy war about closing/not closing PHP tags. I just want to know, what this has to error reporting, because for several months daily programming in PHP I didn’t
Will
parsing error-handling yacc
Still learning yacc and flex, and ran across a scenario that the how-to’s and tutorials that I have do not cover. I am trying to parse a file, and as I’m going along, I’m doing some secondary error checking in the code I’ve placed in my parser.y file. When I come across something that is lexicographically correct (that is, the parse matches properly) but logically incorrect (unexpected value or inappropriate value), how do I get yyparse to exit? Also, can I have it return an error code back to m
Web site is in building