• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

survivor

Banned
Have any of you guys taken any digital image processing course in university or know anything about the subject? There is a course I can take next semester (uses this book) and was hoping to get some opinion on the subject.
 

upandaway

Member
Sorry to ask another after 3 questions in a row, but does anyone know of a good overview/tutorial of JavaFX (in Java 7)? All I can find are lazy Youtube videos.
 

Jokab

Member
Is there a way to translate JAVA to UML Diagrams? Or perhaps software that translate code to UML Diagrams?

Anyone know how to covert .exe, installer back to code and vice versa?

The Eclipse plug-in STAN can generate UML for you. Also good for general structural analysis.
 

Slavik81

Member
Why does 'gvimdiff' return to the shell immediately? Other GUI applications like firefox don't return until I close them.

I'm trying to use gvimdiff as my diff viewer with an archaic SCM, but the tool deletes the temporary files used for the diff when the diff program returns. Then the gvim gui finishes loading and tries to open the now deleted files. If I could just make gvimdiff block until I closed it, all would be well.

EDIT:
Code:
 -f          Foreground.  For the GUI version, Vim will not fork and detach from the shell it was started in.
Welp, I guess I should have RTFM.
 
Ok, I need help with my Java homework. I have to multiply three inputs from users and output the results in a display message. The example shows "10*20*30=6000". I can get it so if the user enters 10, 20 and 30 for the three inputs the display shows 6000. But I can not get it to display the full "10*20*30=6000". Anyone?
 
Ok, I need help with my Java homework. I have to multiply three inputs from users and output the results in a display message. The example shows "10*20*30=6000". I can get it so if the user enters 10, 20 and 30 for the three inputs the display shows 6000. But I can not get it to display the full "10*20*30=6000". Anyone?

while getting input
->get input
->append to string input
->append *

?
 

usea

Member
Ok, I need help with my Java homework. I have to multiply three inputs from users and output the results in a display message. The example shows "10*20*30=6000". I can get it so if the user enters 10, 20 and 30 for the three inputs the display shows 6000. But I can not get it to display the full "10*20*30=6000". Anyone?
Provide more information.
 

iapetus

Scary Euro Man
Ok, I need help with my Java homework. I have to multiply three inputs from users and output the results in a display message. The example shows "10*20*30=6000". I can get it so if the user enters 10, 20 and 30 for the three inputs the display shows 6000. But I can not get it to display the full "10*20*30=6000". Anyone?

Show us your code.
 
Never mind I figured it out. For reference it was:

JOptionPane.showMessageDialog(null, numOne + "*" + numTwo + "*" + numThree + "=" + total);

I didn't think to use "*" to separate the inputs.
 

TheExodu5

Banned
Have any of you guys taken any digital image processing course in university or know anything about the subject? There is a course I can take next semester (uses this book) and was hoping to get some opinion on the subject.

I have...it wasn't that exciting of a course, to be honest. A lot of matrix math and Matlab work.
 

mackattk

Member
This weeks C++ assignment was a bit easier than last weeks, but I still get that rush and feeling of accomplishment when I can get the program to run with no errors, especially if it ran on my first try. It is like a huge weight being lifted off my shoulders.

Maybe it is just because I am still new to this, but I will never get tired of that, and I hope that feeling won't end after completing future projects. It is one of the reasons why I am trying to get into this field. My current job is stagnating, and I don't get any sense of accomplishment, no matter how much I produce or how hard I work.

Either way, programming is a lot more fun when your code works correctly.
 
Does anyone know why the following C# code is giving me an error?

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace NullableTypes
{
    public struct MyNullable<T> where T : struct
    {
        public MyNullable(T value)
        {
            this.hasValue = true;
            this.value = value;
        }
        
        private bool hasValue;
        public bool HasValue
        {
            get
            {
                return hasValue;
            }
        }


        private T value;
        public T Value
        {
            get
            {
                if (!hasValue)
                {
                    throw new InvalidOperationException("no value");
                }

                return value;
                }
        }

        public static explicit operator T(MyNullable<T> value)
        {
            return value.Value;
        }

        public static implicit operator MyNullable<T>(T value)
        {
            return new MyNullable<T>(value);
        }

        public override string ToString()
        {
            if (!HasValue)
                return String.Empty;

            return this.value.ToString();
        }

    }

    class Program
    {
        static void Main(string[] args)
        {

            MyNullable<int> x;
            x = 4;
            x += 3;
            if (x.HasValue)
            {
                int y = x.Value;
            }

        }
    }
}

I'm getting an error on the x += 3; line. As far as I can tell this should work.
 

tokkun

Member
I'm not a C# programmer, but from my knowledge of C++, I would guess the issue is that you have not defined the += operator for MyNullable<T>
 

usea

Member
Does anyone know why the following C# code is giving me an error?

I'm getting an error on the x += 3; line. As far as I can tell this should work.
Did you read the error? Why didn't you post the error? The text of the error is the single most important thing in fixing the problem. In fact it's often the only thing that matters at all.

For the love of god, read and post the error message.

I ran your code for you, and here is the error:
Operator '+=' cannot be applied to operands of type 'NullableTypes.MyNullable<int>' and 'int'

It's not just the += operator, but even the + operator wouldn't work. Your class doesn't overload any of those operators, so you can't simply add an int and a MyNullable<int>.

Here's an msdn page on operator overloading in C# http://msdn.microsoft.com/en-us/library/aa288467(v=vs.71).aspx

You'll find it's more difficult than usual in your case though, since your class is generic. You can't add two arbitrary types T and T, and you can't constrain your types to only things that are addable. You'll probably end up having to implement a bunch of special cases for each type. Here's a stackoverflow question on the topic http://stackoverflow.com/questions/...or-overloading-for-a-generic-class-in-c-sharp
 
Did you read the error? Why didn't you post the error? The text of the error is the single most important thing in fixing the problem. In fact it's often the only thing that matters at all.

For the love of god, read and post the error message.

I ran your code for you, and here is the error:


It's not just the += operator, but even the + operator wouldn't work. Your class doesn't overload any of those operators, so you can't simply add an int and a MyNullable<int>.

Here's an msdn page on operator overloading in C# http://msdn.microsoft.com/en-us/library/aa288467(v=vs.71).aspx

You'll find it's more difficult than usual in your case though, since your class is generic. You can't add two arbitrary types T and T, and you can't constrain your types to only things that are addable. You'll probably end up having to implement a bunch of special cases for each type. Here's a stackoverflow question on the topic http://stackoverflow.com/questions/...or-overloading-for-a-generic-class-in-c-sharp

This is the error:

error CS0019: Operator '+=' cannot be applied to operands of type 'NullableTypes.MyNullable<int>' and 'int'

Problem is that the Microsoft .NET implementation doesn't overload any operators and yet still works. I'm trying to figure out why that one works and mine doesn't.

edit: I should mention that this is an example from the book Professional C# and .NET 4.5. So it's driving me crazy that it doesn't work.

edit2: I'm basically trying to do the same thing as this
http://www.codeproject.com/Articles/275471/Nullable-Types-in-Csharp-Net

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

edit3: Found the solution (well kind of). Attempt to describe it below for those who might be interested.

The Nullable<T> type in C# has "special" properties in the CLR that allow it to "lift" the operators of the type T. A custom Nullable type like mine above has no way of telling the CLR to do the same, so tokkum and usea above were right in that implementation is needed for the operators of each type.

Much better explanation here:
http://stackoverflow.com/questions/...erator-work-for-nullablet-when-is-not-defined

Thanks tokkum and usea for your help.
 

Onemic

Member
Code:
	 int changeCents = (((cashTendered - totalPrice) - changeLoonies) * 100);
	 printf("Change in cents: %f\n", changeCents);

	 return 0;

Finally found the solution to my problem. I don't even know how I missed something so simple
 

tokkun

Member
Code:
	 int changeCents = (((cashTendered - totalPrice) - changeLoonies) * 100);
	 printf("Change in cents: %f\n", changeCents);

	 return 0;

Finally found the solution to my problem. I don't even know how I missed something so simple

Like I said earlier, this solution has a subtle bug in it. You are using binary floating point, which cannot accurately represent all fractional decimal values. For some numbers, the actual value will be slightly more or slightly less than what you want. The C-style implicit float-to-integer cast truncates. Therefore for the values that are slightly less, this approach will generate an answer that is one cent less than the correct value.

Here's an example. Let's say that the closest single-precision binary floating point representation of 3.74 was actually something like 3.73999995 (I'm just making that up as an example, it's not the real value).

If you multiply by 100, you get 373.999995. When you convert to int, it truncates, so you get 373, even the the number you actually wanted was 374.
 

jokkir

Member
Yup that's fine.

This is an intro to C programming course, so its being taught like everyone is 100% new to programming in general and not just C. Functions have not been introduced yet. Printf and scanf have as they are the most basic of concepts of programming in C.

To give you an idea of this here is the homepage and where we are at(We have only done up to expressions under week 2 and the computations workshop that I'm doing is suggested at the end of the Expressions section)

lol you're in the same school and program as me. Get ready for later classes ;)
 
Thanks for the input.

I think I'm just gonna take the computer graphics course instead.

Digital image processing is not that interesting (at least to me) but computer vision is pretty awesome and you need to know image processing in order to understand computer vision (or computational photography, which is also quite interesting).

Those are some of the things I learned in my image processing class:
Image representation (image as an array of RGB values)
A bit of sampling theory (digital signal processing)
Point operations (e.g. greyscale conversion, histogram equalization, threshold operation)
Filters and convolution (Box filter, Gaussian filter, edge detecting filters)
Global operations (image transforms, Fourier transform, discrete cosine transform and so on)
Morphology

It's quite a lot of math (some calculus, some linear algebra) but I thought most of it was pretty intuitive.
 
Is there a way to convert a desktop application back to source code? I noticed this software was created using Adobe Flash builder, but I do not know how to convert it back to source code (mxml, as, fxg).
 

usea

Member
Is there a way to convert a desktop application back to source code? I noticed this software was created using Adobe Flash builder, but I do not know how to convert it back to source code (mxml, as, fxg).
In general, there is significant information lost when you change source code into an executable. Native applications have severe information lost, while some other VM systems like the ones used by Java or C# have less information lost, but it's still significant.

A term used for converting an application to source code is Decompiling. You want to search for a decompiler that will decompile the program. Very often the results will be horrible and almost unreadable. Sometimes, especially with more expensive tools, the results will be readable.

In the vast majority of scenarios you absolutely cannot recover the original source. But you can get something that might sort of resemble it, kinda.

Try googling Adobe Flash Builder Decompiler. It seems like a popular one is Sothink, although it seems targeted to SWF files (flash). I don't know if an swf made into an executable will work, you'd have to google around for that. Also a lot of flash stuff has been run through an obfuscator, which is a tool specifically to make the results of decompilation less useful. Flash in general decompiles well, compared to other stuff.
 
For home work I have to "write a program that reads a set of integers and then finds and prints the sum of the even and odd integers". My instructor insisted we should use a for/while loop. I know I need to read more on the for/while loops, yet I currently don't recognize how I should structure my code, this is what I have so far.

#include<iostream>
using namespace std;
int main ()
{
int numb1,numb2,numb3;
cout << "Please, enter three integers" << endl;
cin >> numb1 >> numb2 >> numb3;


int sum_even, sum_odd;


for( (numb1 % 2 == 0) )
 
I haven't had an issue this difficult for me in a while, especially considering how long I've been searching online without any answers.

I'm taking a network programming class, havent done c++ in a while, and we are doing network socket programming.

Got to make a tcp connection between a client and server and transfer a FILE.

So far I have the socket and connection created. I can transfer a message between the two. However, I am completely stumped as to how I would go about transfering a file from the client to server.

Microsofts MSDN website has been pretty helpful so far, but am I on the right track using the "transmitFile" function?
TransmitFile Function
 

Onemic

Member
Like I said earlier, this solution has a subtle bug in it. You are using binary floating point, which cannot accurately represent all fractional decimal values. For some numbers, the actual value will be slightly more or slightly less than what you want. The C-style implicit float-to-integer cast truncates. Therefore for the values that are slightly less, this approach will generate an answer that is one cent less than the correct value.

Here's an example. Let's say that the closest single-precision binary floating point representation of 3.74 was actually something like 3.73999995 (I'm just making that up as an example, it's not the real value).

If you multiply by 100, you get 373.999995. When you convert to int, it truncates, so you get 373, even the the number you actually wanted was 374.

Thanks for the tip.

Just for reference, what would be best to use in this situation instead? That fgets() function?

Also, I want to create a stat that outputs the win percentage of a player. What would be the best way of going about this?
 
For home work I have to "write a program that reads a set of integers and then finds and prints the sum of the even and odd integers". My instructor insisted we should use a for/while loop. I know I need to read more on the for/while loops, yet I currently don't recognize how I should structure my code, this is what I have so far.

#include<iostream>
using namespace std;
int main ()
{
int numb1,numb2,numb3;
cout << "Please, enter three integers" << endl;
cin >> numb1 >> numb2 >> numb3;


int sum_even, sum_odd;


for( (numb1 % 2 == 0) )

Are you required to read in an arbitrary amount of integers or do you just need 3? If you need an arbitrary number, you're going to have to use a vector (or something similar) to store the numbers and a loop to read them as well.

You seem to be on the right path with regards to the logic, but if you're only reading in a fixed number of integers, you don't need a loop. You could just say something like
Code:
if num1 % 2 == 0 add it to evenSum
else add it to oddSum
if num2 % 2 == 0 add it to evenSum
else add it to oddSum
...
This should already give you an idea of how to loop over the list/vector of integers that you've read.
 

tokkun

Member
Thanks for the tip.

Just for reference, what would be best to use in this situation instead? That fgets() function?

There are a few options. I don't know if any of them is "best". In your case, a simple solution would just be to add a small value before doing the cast:

Code:
int changeCents = (((cashTendered - totalPrice) - changeLoonies) * 100 + [B]0.5[/B]);
printf("Change in cents: %f\n", changeCents);

return 0;

Basically, when you add 0.5 to a float before casting it to an int, this is an easy way of achieving round-to-nearest rather than truncate (assuming the value is positive).
 
How dooable is the job if you were asked to work on an ongoing JAVA/FLEX project, but there are no technical documents, no technical coworkers, there's one version of the source code ( packaged in a zip file, but not in under version control), and the software is not functional.

The previous programmer left 7 months ago along with most of the work.
 
Are you required to read in an arbitrary amount of integers or do you just need 3? If you need an arbitrary number, you're going to have to use a vector (or something similar) to store the numbers and a loop to read them as well.

You seem to be on the right path with regards to the logic, but if you're only reading in a fixed number of integers, you don't need a loop. You could just say something like
Code:
if num1 % 2 == 0 add it to evenSum
else add it to oddSum
if num2 % 2 == 0 add it to evenSum
else add it to oddSum
...
This should already give you an idea of how to loop over the list/vector of integers that you've read.

Thank you sir! I followed your logic and I have successfully finish the problem
Code:
 #include<iostream>
using namespace std;
int main ()
{
	int numb;
	cout << "Please, enter a integer. To calculate the numbers enter 0 " << endl;
	cin >> numb;
	[I]//Will ask the user for a integer[/I]

	int sum_even, sum_odd;
	sum_even = 0;
	sum_odd = 0;
	[I]//variable to determine even/odd[/I]

	while( (numb  != 0 ) )[I]//keeps the program running until the user decides to press 0 to calculate[/I]
	{ 
		if ( (numb % 2) == 0 )[I]//decides if # is even[/I]
		 {sum_even = sum_even + numb;}[I]//even # will be stored and added[/I]
		 else if ( (numb % 2) !=0 )[I]//decides if # is odd[/I]
		 {sum_odd = sum_odd + numb;}[I]//odd # will be stored and added
		 else [/I]
			 cout << "You need to enter another input" << endl;
		 
		[I] //Will be the recurrent prompt for user until 0 is enter[/I]
		 cout << "Enter another number ";
		 cin >> numb;
	}

	cout << "the sum of all your odd numbers is " << sum_odd << endl;[I]//outputs the sum of odds[/I]
	cout << "the sum of all your even numbers is " << sum_even << endl;[I]//outputs the sum of evens
[/I]
system("pause");
}
 

Onemic

Member
Yeah, I'm in CPA but might switch to CPD so I can graduate faster. They're essentially the same thing anyway

Are you doing co-op? Do you know of any of the employers that you can net a job with? That's the only reason why I'm taking CPA over CPD.
 

jokkir

Member
Are you doing co-op? Do you know of any of the employers that you can net a job with? That's the only reason why I'm taking CPA over CPD.

I'm not doing co-op but you can apply for co-op even when in CPD. What they do is just put you to CPA when you're doing co-op and put you back once you're done. I'm not exactly sure who are the employers are but I assume it's this:

https://www.senecacareerlink.com/careerlink/students.do;jsessionid=D5D911FB772C7E123679D3004FEB9D92

I can try to ask my friend who is in co-op to what options of employers they offer you.
 
Thank you sir! I followed your logic and I have successfully finish the problem
Code:
 code

From a quick look, this looks good. A few small things:
It doesn't really matter in this case, but don't use system("pause"), just do cin >> numb; at the end. (system("pause") will only work on Windows and it's slow).
Pick an indent style you like and stick with it. Proper formatting is really important for readable code.
An integer can't really be anything else other than even or odd, right? It's enough to put if(numb % 2 == 0) and after that an else there, there are no other possible cases (except maybe if your CPU is overheating enough or something)
Try to put the comments in their own lines, it makes formatting the code after you've written it easier.
 

Slavik81

Member
From a quick look, this looks good. A few small things:
It doesn't really matter in this case, but don't use system("pause"), just do cin >> numb; at the end. (system("pause") will only work on Windows and it's slow).

You have a lot of good advice, but I kinda laughed a bit when when I got to this.

(It is slow, but given its purpose, that really doesn't matter. Though, you still shouldn't use system("pause") in all but the most hacked-together code.)
 
You have a lot of good advice, but I kinda laughed a bit when when I got to this.

(It is slow, but given its purpose, that really doesn't matter. Though, you still shouldn't use system("pause") in all but the most hacked-together code.)

Funny you say that my lab instructor was saying I should use return 0;
When you say slow are referring to execution. In comparison how is return 0;
 
Funny you say that my lab instructor was saying I should use return 0;
When you say slow are referring to execution. In comparison how is return 0;

Return 0 is just an extra line or two of assembly code added to the set of instructions that are already present to denote when to exit the function already so it's extremely fast.
 
How dooable is the job if you were asked to work on an ongoing JAVA/FLEX project, but there are no technical documents, no technical coworkers, there's one version of the source code ( packaged in a zip file, but not in under version control), and the software is not functional.

The previous programmer left 7 months ago along with most of the work.

How the fuck did you get stuck with this situation?
 
How dooable is the job if you were asked to work on an ongoing JAVA/FLEX project, but there are no technical documents, no technical coworkers, there's one version of the source code ( packaged in a zip file, but not in under version control), and the software is not functional.

The previous programmer left 7 months ago along with most of the work.
Get your debugger ready and start writing tests.

Also, if you're not really damn good at Java and Flex, get good at Java and Flex. You're gonna need all the expertise you can muster to fly blind into somebody else's (probably crappy) code.

How the fuck did you get stuck with this situation?
More common than you'd imagine! Small companies and academia do this annoying thing all the time where they just let stuff languish unfinished, then somebody remembers it and some poor engineer or grad student (depending) finds themselves staring at 40000 lines of wtf.

I remember a coworker ended up simply rewriting one such program from scratch.
 

d[-_-]b

Banned
Little help :(? Php is a bish... So the first query is called, for inserting into users table but the second two are never called or if they are they throw some sort of error I can't seem to find.

Code:
	public function register_account()
	{
		/* Create User Account */
		$role = 1;
		$project_id1 = 1;
		$project_id2 = 2;
		$email = mysql_real_escape_string($_POST['email']);
		$first_name = mysql_real_escape_string($_POST['first_name']);
		$last_name = mysql_real_escape_string($_POST['last_name']);
		$password = Laravel\Hash::make($_POST['password']);

		/* Check if email exists if so change the password on it */
		$test_query = "select * from users where email = '$email' and deleted = 0 LIMIT 1";
		$test_result = mysql_query($test_query);

		if(mysql_num_rows($test_result) >= 1)
		{
			$query = "
			UPDATE `users`
			SET
				password = '{$password}',
				firstname = '{$first_name}',
				lastname = '{$last_name}'
			WHERE email = '{$email}' AND deleted = 0
			LIMIT 1";
			return false;
		}
		else
		{
			$query = "
			INSERT INTO users(
				role_id,
				email,
				password,
				firstname,
				lastname,
				created_at
			)VALUES(
				'1',
				'$email',
				'$password',
				'$first_name',
				'$last_name',
			now()
			)";
			$result = mysql_query($query);
			$test_result = mysql_query($test_query);
			$row = mysql_fetch_row($test_result);
			$query2 = "
			INSERT INTO project_users(
				user_id, 
				project_id, 
				role_id, 
				created_at,
				updated_at
			)VALUES(
				'$row[0]',
				'$project_id1',
				'1',
			now(),
			now()
			)";
			$result = mysql_query($query2);
			$query3 = "
			INSERT INTO project_users(
				user_id, 
				project_id, 
				role_id, 
				created_at,
				updated_at
			)VALUES(
				'$row[0]',
				'$project_id2',
				'1',
			now(),
			now()
			)";
			$result = mysql_query($query3);
		}

		return true;
	}
 
d[-_-]b;82951429 said:
Little help :(? Php is a bish... So the first query is called, for inserting into users table but the second two are never called or if they are they throw some sort of error I can't seem to find.

What is the first column of the table `users'? By the way, in code like this, you should never user `*' in a select. First, it's harder to read; Second, what if someone recreate the table and decides, for the kick of it, to change the columns order? Lots of fun.

Also, if you have the errors, that would be great.
 

d[-_-]b

Banned
What is the first column of the table `users'? By the way, in code like this, you should never user `*' in a select. First, it's harder to read; Second, what if someone recreate the table and decides, for the kick of it, to change the columns order? Lots of fun.

Also, if you have the errors, that would be great.

As I wish I could figure out how to log errors on php, as a poor developer, thought let me use a free resource aka tinyissue for users to log issues for me to easily track. Bought a vps, worst decision of my life lol, setting up a web server was more work, because apache+php wouldn't let tiny issue work, then someone helped me setup nginx+php to get tinyissue working, originally this all came about from my freehost going down taking my original tinyissue edit with it.

https://github.com/mikelbring/tinyissue/blob/master/install/mysql-structure.php
Code:
"# Create Users Table
CREATE TABLE IF NOT EXISTS `users` (
  `id` bigint(20) unsigned NOT NULL auto_increment,
  `role_id` bigint(20) unsigned NOT NULL default '1',
  `email` varchar(255) default NULL,
  `password` varchar(255) default NULL,
  `firstname` varchar(255) default NULL,
  `lastname` varchar(255) default NULL,
  `language` varchar(5) default NULL,
  `created_at` datetime default NULL,
  `updated_at` datetime default NULL,
  `deleted` int(1) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
Long story short... I checked my nginx log folder and don't see any errors logged, also checked php5-fpm log folder and nothing there. Also I made a quick hack to allow users to register as tinyissue doesn't provide a registration page :(. User registration goes fine but I also need to insert them into the project users table for them to have access to the projects to post issues in.
Code:
"# Create Projects Users Table
CREATE TABLE IF NOT EXISTS `projects_users` (
  `id` bigint(20) NOT NULL auto_increment,
  `user_id` bigint(20) default '0',
  `project_id` bigint(20) default '0',
  `role_id` bigint(20) default '0',
	`created_at` datetime default NULL,
 	`updated_at` datetime default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
 
d[-_-]b;82953657 said:
As I wish I could figure out how to log errors on php, as a poor developer, thought let me use a free resource aka tinyissue for users to log issues for me to easily track. Bought a vps, worst decision of my life lol, setting up a web server was more work, because apache+php wouldn't let tiny issue work, then someone helped me setup nginx+php to get tinyissue working, originally this all came about from my freehost going down taking my original tinyissue edit with it.

https://github.com/mikelbring/tinyissue/blob/master/install/mysql-structure.php

Long story short... I checked my nginx log folder and don't see any errors logged, also checked php5-fpm log folder and nothing there. Also I made a quick hack to allow users to register as tinyissue doesn't provide a registration page :(. User registration goes fine but I also need to insert them into the project users table for them to have access to the projects to post issues in.

I really can't see what is wrong from that code. Since it seems to be your code, can you add some error checks on the mysql calls, that could help to pinpoint where it is failing.
 
d[-_-]b;82971809 said:
Just echo data to try to debug? Because my knowledge of php is limited...

Sorry for the delay, I had to go to sleep.

http://stackoverflow.com/questions/9619610/how-can-i-debug-why-simplest-mysql-query-returns-false

To get the error from mysql, you'll need to user `mysql_error()' because the calls to mysql_* fail silently.

Calls to mysql_* returns False on failure, so you can do:

Code:
$var = mysql_query($query) [B]or trigger_error(...)[/B];

Note that if your page is live, using `trigger_error(...)' could be a security risk as it inserts into the resulting document the location of the script on the file system and the line number where the error occured.

You can also use `die(message)' in place of `trigger_error', which will cause the script to terminate with the message passed as argument.

Code:
$var = mysql_query($query) or die(mysql_error());

You get less information but it gives less informations to those who shouldn't see it.
 

d[-_-]b

Banned
Sorry for the delay, I had to go to sleep.

http://stackoverflow.com/questions/9619610/how-can-i-debug-why-simplest-mysql-query-returns-false

To get the error from mysql, you'll need to user `mysql_error()' because the calls to mysql_* fail silently.

Calls to mysql_* returns False on failure, so you can do:

Code:
$var = mysql_query($query) [B]or trigger_error(...)[/B];

Note that if your page is live, using `trigger_error(...)' could be a security risk as it inserts into the resulting document the location of the script on the file system and the line number where the error occured.

You can also use `die(message)' in place of `trigger_error', which will cause the script to terminate with the message passed as argument.

Code:
$var = mysql_query($query) or die(mysql_error());

You get less information but it gives less informations to those who shouldn't see it.
Thanks Hugh, tried switching to using mysql pdo with a prepared statement yeah it didn't give me any errors after I fixed basic syntax errors but still didn't insert into the table, will give what you said a shot when I get home.
 

Gartooth

Member
Have to do a project in C language and I'm having an awful time, can't even get simple statements to make a test from.

For instance say I have this code. (this is just a fragment of the code where I'm getting errors)

Code:
void main()
	{
		int center = 4;
		char board[8][8];
		int i, j;
		for(i = 0; i < 8; i++)
			for(j=0; j < 8; j++)
				board[i][j] = "-";

		board[center][center] = board[center+1][center+1] = "B";
		board[center+1][center] = board[center][center+1] = "W";
}

Every time I try to assign a value such as "-", "B", or "W" I get an error stating:

"assignment makes integer from pointer without a cast [enabled by default]"

Can someone help me work this out?
 

arit

Member
Have to do a project in C language and I'm having an awful time, can't even get simple statements to make a test from.

For instance say I have this code. (this is just a fragment of the code where I'm getting errors)

Code:
void main()
	{
		int center = 4;
		char board[8][8];
		int i, j;
		for(i = 0; i < 8; i++)
			for(j=0; j < 8; j++)
				board[i][j] = "-";

		board[center][center] = board[center+1][center+1] = "B";
		board[center+1][center] = board[center][center+1] = "W";
}

Every time I try to assign a value such as "-", "B", or "W" I get an error stating:

"assignment makes integer from pointer without a cast [enabled by default]"

Can someone help me work this out?

chars are assigned with ' ', not " ".
You might want to use some braces and depending on the environment int main() instead of void main().
 

Gartooth

Member
chars are assigned with ' ', not " ".
You might want to use some braces and depending on the environment int main() instead of void main().

Thank you! Can't believe it was something like that.

Also say I have a loop such as

Code:
int k;

for(k = 1; k <= 8; k++){
     printf(k);
}

I also get a similar error that says I make a "pointer from integer without a cast", when all I want to do is print 1 through 8.
 
Top Bottom