Jump to content

plz help!

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
10 replies to this topic

#1
niko619

niko619

    Member

  • Members
  • PipPip
  • 23 posts
hey peepz i have a problem. ok so i was trying this tutorial
(forum.codecall.net/php-tutorials/13410-register-upload-photo-have-new-page-each-user-after-registration.html)
i got the tables just fine but when i try the 'regmee2' part (procedure i think) it doesnt work it keeps saying (error 1064 syntax error) or something along those lines. someone pls help me?

ps i had to put link to tut in code box because of my post count.

#2
niko619

niko619

    Member

  • Members
  • PipPip
  • 23 posts
anyone plz, its so frustrating Posted Image

#3
debtboy

debtboy

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 916 posts

niko619 said:

anyone plz, its so frustrating Posted Image

Hi niko619,
When debugging, be patient and look over the code carefully.

It looks like you've identified the problem area.
Look at your insert queries carefully!!
You have 3 tables images, users and user_images.
You have 3 insert queries, look close at the table names your trying to insert to.

Now you see it, don't you...
The table name is users not dbo_users

If a schema/user was being used then dbo.users would
be the syntax, but your not using a schema ref. in the
other insert queries so stick to just users and hopefully
it's not a reserved word.

Most important, when something doesn't work...
Start breaking it down into simpler expressions until it works,
then build it back up.

Good Luck fellow forum newbie!! ;)
joined about the same time

#4
niko619

niko619

    Member

  • Members
  • PipPip
  • 23 posts
hey thanx for the reply. ive tried what you said still same syntax error, ive had to change my semicolons to comas for the procedure to get past the 1st part. i have changed all names to what i thought they should be, and its always the same error on the same line. (error below)

#1064 - 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 'insert into users (user_name,password,firstname,lastname,email) values

(user_na' at line 6 


#5
debtboy

debtboy

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 916 posts
Then you should break it down...
Drop the stored procedure and run 3 individual queries directly.
It's late, work with you tomorrow if you don't have it resolved by then.

#6
debtboy

debtboy

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 916 posts
Hi niko,
Any progress?

If your still having a problem, post all the code so I can take a look.
We'll fix it, php w/ MySQL is very straightforward.

At work now, but I'll have time at home later.

Hang in there...
but NOT by the neck!! :P

#7
niko619

niko619

    Member

  • Members
  • PipPip
  • 23 posts

debtboy said:

Hi niko,
Any progress?

Hang in there...
but NOT by the neck!! :P

lol thanx. im trying php query's at the moment. getting error still but trying to fix it. fingers crossed. i will post later and tell you if i have succeeded or failed lol.

#8
debtboy

debtboy

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 916 posts
Hope you succeeded, if not
post everything and we'll find the problem

#9
niko619

niko619

    Member

  • Members
  • PipPip
  • 23 posts
k ive tried doing the procedure from php still same line but i get this error instead
Parse error: syntax error, unexpected T_STRING
always this code
CREATE DEFINER=`root`@`localhost` PROCEDURE  `forum`.`regmee2`(img2 varchar(200), usrnme varchar(20), psswrd varchar(50), frstnme varchar(50),lstnme varchar(50),email varchar(255))


then i tried the query insert and it comes up with "query was empty"
this is the code
$query = mysql_query ("INSERT INTO images (image_url) values (img2)");

$query = mysql_query ("INSERT INTO users ('$user_name/$file','$user_name','$password','$firstname','$lastname','$email')");

$query = mysql_query ("INSERT INTO user_images (user_id ,image_id )");

$result =mysql_query ($query,$conn) or die (mysql_error());

i think its what it should be but remember im a noob lol:rolleyes:

#10
debtboy

debtboy

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 916 posts
OK niko,
I can't debug without seeing all your code,
so here I made an example that will work
with your forum database and the users table.

Call up data_input.php
fill in the boxes and submit
then data_input_script.php will insert your entries into the database

If your successful, then you can build back up to 3 queries, etc...
GOOD LUCK!!

your current database name: forum
current table name and description: users
user_id int(10) NOT NULL AUTO_INCREMENT, (primary key)
user_name - varchar(20) DEFAULT NULL,
password - varchar(50) DEFAULT NULL,
firstname - varchar(50) DEFAULT NULL,
lastname - varchar(50) DEFAULT NULL,
bad - tinyint(1) DEFAULT NULL,
email - varchar(255) DEFAULT NULL,
role_id - int(10) DEFAULT NULL,




put this in a file named data_input.php
<?php

echo "<html>";
echo "<body>";
echo "<form action='data_input_script.php' method='post'>";
echo "<br />User Name: <input type='text' name='input_name' size='20' maxlength='20' /><br />";
echo "<br />Password: <input type='text' name='input_password' size='50' maxlength='50' /><br />";
echo "<br />First Name: <input type='text' name='input_first' size='50' maxlength='50' /><br />";
echo "<br />Last Name: <input type='text' name='input_last' size='50' maxlength='50' /><br />";
echo "<br />Email: <input type='text' name='input_email' size='255' maxlength='255' /><br />";
echo "<br /><br />";
echo "<br /><input type='submit' />";
echo "</form>";
echo "</body>";
echo "</html>";

?>

fill in your password at $passwordname = " " and put this
code in a file named data_input_script.php
<?php

$databasename = "forum";
$hostname = "localhost";
$username = "root"
$passwordname = "your_password"


  //OPEN MYSQL CONNECTION
  $connectionname = mysql_connect($hostname, $username, $passwordname) or die ("Unable to Connect");

  //SELECT DATABASE
  mysql_select_db($databasename, $connectionname) or die ("Unreachable Database");

  //QUERY
  $queryname = "INSERT INTO users
  (user_name,
  password,
  firstname,
  lastname,
  email)
  VALUES
  ('$_POST[input_name]',
  '$_POST[input_password]',
  '$_POST[input_first]',
  '$_POST[input_last]',
  '$_POST[input_email]')

  //EXECUTE QUERY
  mysql_query($queryname, $connectionname);

  //CLOSE CONNECTION
  mysql_close($connectionname);

  print("Record Inserted");

?>

Don't build a released internet site with this structure,
you need to hide the database connection info
in a directory ABOVE the public one, but for testing
this structure is easily understood.

Edited by debtboy, 01 September 2009 - 10:48 PM.


#11
niko619

niko619

    Member

  • Members
  • PipPip
  • 23 posts
ok the whole code is actually from a tutorial on this site heres the link
http://forum.codecal...gistration.html