Jump to content

Recommended Posts

Hello,

    I am struggling with this. I am trying to create a list box that is populated by a mysql data base. I am running this script alone to figure it out before I add it to my working form.

 

I keep getting this error:

 

Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\list\list.php on line 10

 

I believe it has something to do with $result but why?

<?php

mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("time_sheets") or die(mysql_error());

$result = @mysql_query("SELECT jobs FROM job");

print "<p>Select a Job:\n";
print "<select name="jobs">\n";
while ($row = mysql_fetch_assoc($result))
{
$jobs = $row['jobs'];
print "<option value=$jobs>\n";
}
print "</select>\n";
print "</p>\n";

?>

 

can anyone help me with this. I am complete newb so explinations as simple as possible are extremely welcome, however, all help is very appreciated. Thank you in advance.

 

Link to comment
https://forums.phpfreaks.com/topic/189668-parse-error-unexpected-t_string/
Share on other sites

okay

if i do this

echo "Hello World";

PHP echos the string between the quotes,

 

BUT

echo "Hello "world"";

doesn't make sense! so i need to tell PHP that some of the quotes i wish to echo, to do this i "escape them" with the slash

echo "Hello \"world\"";

you could also use single quotes

ie

echo 'Hello "world" ';

okay

if i do this

echo "Hello World";

PHP echos the string between the quotes,

 

BUT

echo "Hello "world"";

doesn't make sense! so i need to tell PHP that some of the quotes i wish to echo, to do this i "escape them" with the slash

echo "Hello \"world\"";

you could also use single quotes

ie

echo 'Hello "world" ';

 

Thank you very much!

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.