בעיה נתקתי

shai4u2

New member
בעיה נתקתי

<?php @include("config.php"); $link = mysql_connect("$host", "$dbpass", "$dbuser") or die (mysql_error()); mysql_select_db("$dbname", $link); mysql_query("INSERT INTO masin (id, user, pass, email, icq, homepage, mysite, age, sex, onmyself) VALUES ("$id", "$user", "$pass", "$email", "$icq", "$homepage", "$mysite", "$age", "$sex", "$onmyself")");​
ברצוני לבנות דף הרשמה אך אינני יודע איך להמשיך תסבירו לי בבקשה איך להמשיך מכאן כי נתקעתי תודה לכל העוזרים
 

shai4u2

New member
הנה עשיתי אך יש בעיה בשורה 7

הנה הקוד
<?php @include("config.php"); if (isset($user,$pass,$email,$icq,$homepage,$age,$sex,$onmyself)) { $link = mysql_connect("$host", "$dbpass", "$dbuser") or die (mysql_error()); mysql_select_db("$dbname", $link); mysql_query("INSERT INTO members (id, user, pass, email, icq, homepage, age, sex, onmyself) VALUES ("$id", "$user", "$pass", "$email", "$icq", "$homepage", "$age", "$sex", "$onmyself")"); echo "ההרשמה נתבצעה בהצלחה!!!"; }else{ ?> <html> <body dir="rtl"> <form action="signup.php" method="post"> שם משתמש : <input type="text" name="user"><br> סיסמא : <input type="password" name="pass"><br> כתובת דוא"ל : <input type="text" name="email"><br> מספר ICQ : <input type="text" maxlength="9" name="icq"><br> דף בית : <input type="text" name="homepage"><br> גיל : <input type="text" name="age" maxlength="2"><br> על עצמי : <br> <textarea name="onmyself" rows="10" cols="40"> </textarea><br><br> <center><input type="submit" value="הרשם"><input type="reset" value="נקה שדות"></center> </form> </body> </html> <? } ?>​
מה הבעיה ?? איפה טעיתי???
 

DannyZ

New member
מה ההודעת שגיאה?

כתבתי כבר אתמול שלphp יש קטע עם גרשיים. זה נקרא special charcter כשזה בתוך מחרוזת חייבים להגיד לphp לא להתייחס לגרשיים האלה. לכן צריך להשתמש ב \ לדוגמא:
$string = "I then said: "AHAH!" blah blah blah.."; //טעות!!! $string = "I then said: \"AHAH!\" blah blah blah.."; //נכון!!​
שים לב! כתבת בmysql_query() גרשיים בתוך הגרשיים הכלליות. לפני כל גרשים תשים \ וזה יפתור את הבעיה!
 

באפט

New member
נסה את זה

<? include("config.php"); // Is code here vaild? // HTML header, which is common $html .= ´ <html> <body dir="rtl"> ´; if (isset($user, $pass, $email, $icq, $homepage, $age, $sex, $onmyself)) { // Are these global or local variables? how do you know they are set? // $host = ?? // $dbpass = ?? // $dbuser = ?? // $dbname = ?? $link = mysql_connect($host, $dbpass, $dbuser) or die (mysql_error()); mysql_select_db($dbname, $link); // Tip: Define a function for connecting to a DB // SQL queries should be aligned neatly. Also, notice the correct use of quotes: $query = " INSERT INTO members (id, user, pass, email, icq, homepage, age, sex, onmyself) VALUES (´$id´, ´$user´, ´$pass´, ´$email´, ´$icq´, ´$homepage´, ´$age´, ´$sex´, ´$onmyself´) "; mysql_query($query, $link); // Tip: You should also check for an sql_error before announcing success $html .= "ההרשמה נתבצעה בהצלחה!!!"; } else { $html .= ´ <form action="signup.php" method="post"> שם משתמש : <input type="text" name="user"><br> סיסמא : <input type="password" name="pass"><br> כתובת דוא"ל : <input type="text" name="email"><br> מספר ICQ : <input type="text" maxlength="9" name="icq"><br> דף בית : <input type="text" name="homepage"><br> גיל : <input type="text" name="age" maxlength="2"><br> על עצמי : <br> <textarea name="onmyself" rows="10" cols="40"> </textarea><br><br> <center><input type="submit" value="הרשם"><input type="reset" value="נקה שדות"></center> </form> ´; } // Common HTMl footer: $html .= ´ </body> </html> ´; // Always concentrate echoing at one point: echo $html; ?>​
 

shai4u2

New member
בקשה

אם באפשרותך לבדוק שוב את הקוד כי ניראה לי יש בו הרבה טעויות בבקשה ולשלוח לכתובת האימייל שלי שהיא: [email protected]
 

DannyZ

New member
שים לב!

כאשר בתוך מחרוזת משתנה מופיע בתוך גרשיים יחידים (´,´) הוא ייקלט בתור השם של המשתנה ולא בתור ערכו. אתה כתבת:
// SQL queries should be aligned neatly. Also, notice the correct use of quotes: $query = " INSERT INTO members (id, user, pass, email, icq, homepage, age, sex, onmyself) VALUES (´$id´, ´$user´, ´$pass´, ´$email´, ´$icq´, ´$homepage´, ´$age´, ´$sex´, ´$onmyself´) "; וכדי להמנע מזה.. טוב אני לא אחזור על זה.. כבר כתבתי את זה בשרשור הזה...​
 

matroz

New member
you are both correct

it seems that you both are talking about the same thing, when php sees a string starting with ´ (single), it takes the string literaly, meaning that ´$mat´ will be parsed as string named $mat. however, if the strings starts with " (double), it will usually parse the following code correctly - "´$mat´". note that the best way (and the way you should use this) is to do: $q="update matty set mat=´".$mat."´ "; mysql_query($q);
 
למעלה